Answer the question
In order to leave comments, you need to log in
PyQt5 - why does not determine the font size?
Why is the text font size incorrect?
text = self.secret.toPlainText()
font3 = QtGui.QFont(text)
fontinfo = QtGui.QFontInfo(font3)
self.answer.setText(str(fontinfo.pointSize()))
Answer the question
In order to leave comments, you need to log in
in pyqt5, Qstring was cut out and they think that str is better suited for this business .... toPlainText() returns str and even without a format (i.e., it just displays what is visible on the screen):
print (type(text))
<class 'str'>.
from PyQt5 import Qt
app = Qt.QApplication([])
textEdit = Qt.QTextEdit()
textEdit.show()
secret = "<H4>test<H2>L, <H3>L"
textEdit.setText(secret)
html = textEdit.toHtml()
td = Qt.QTextDocument()
td.setHtml(html)
formats = td.allFormats()
print(formats)
app.exec_()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question