Every time I use QFontDialog.getFont()
to get a font, it returns the same QFont
object.
font, ok = QFontDialog.getFont()
print(font)
if ok:
self.lbl.setFont(font)
print(self.lbl.font())
Above is the code segment, and the result is below (I make different choices but the font of the QLabel
and the font I get from getFont()
is always the same one).
/Users/yao/PycharmProjects/QT_test/venv/bin/python /Users/yao/PycharmProjects/QT_test/test/4_2.py
<PyQt5.QtGui.QFont object at 0x10b428748>
<PyQt5.QtGui.QFont object at 0x10b4287b8>
<PyQt5.QtGui.QFont object at 0x10b428748>
<PyQt5.QtGui.QFont object at 0x10b4287b8>
Update:
Below is some information about my environment:
- macOS Mojave
- PyQt5
- Python 3.6
I have tested the codes by @ekhumoro and the results are strange:
BEFORE:
string:.SF NS Text, 13,-1,5,50,0,0,0,0,0
family:.SF NS Text
size:13
AFTER:
string:.SF NS Text, 13,-1,5,50,0,0,0,0,0
family:.SF NS Text
size:13