[PyQt] PyQt 5.7.1 regression : bad font in QTableWidget and QListWidget

Paul atrepaul at yahoo.com
Wed Jan 11 15:16:26 GMT 2017


This is on Windows 7 - 64bit, python 3.5.2.
PyQt5-5.7.1 is installed by "pip install PyQt5"

In PyQt 5.7.1, texts displayed by QTableWidget and QListWidget does not look the same as in previous versions.
So, I looked at the font settings that are used, and found this :
myListWidget.font().family()  :
Returns "Segoe UI" in PyQt 5.3.1 and 5.7.0Returns "MS Shell Dlg 2" in PyQt 5.7.1

myListWidget.font().pointSize() :
Returns 9 in PyQt 5.3.1 and 5.7.0Returns 8 in PyQt 5.7.1

myListWidget.font().pointSizeF() :
Returns 9.0 in PyQt 5.3.1 and 5.7.0Returns 8.25 in PyQt 5.7.1

I guess it's probably a Qt bug, not a PyQt one.

My solution : use a qss styleSheet, containing this for QTableWidget and QListWidget :font-size: 12px;
font-family: "Segoe UI", sans-serif;

That's not a very nice solution, because it will only work on Windows ("Segoe UI" is Windows-specific), but it will do until a real fix is found.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20170111/ecb30c19/attachment.html>

More information about the PyQt mailing list