Answer the question
In order to leave comments, you need to log in
Why can't I open html file in textedit pyqt?
Actually, I want to open an html file and put its text in QTextEdit (PyQT)
I write the following construction:
def showDialog(self):
filename = QtWidgets.QFileDialog.getOpenFileName(self, 'Open file', '/')
file=open(filename[0])
data = file.read()
self.ui.textedit.setPlainText(data)
Answer the question
In order to leave comments, you need to log in
Found the reason
f = open(filename[0],"rb")
data = f.read() data =
data.decode
('utf-8',errors='ignore')
the reason was not in QTextEdit
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question