Qt font size difference across Mac OS and Windows
-
Hello,
I'm developing a Qt (PyQt) app that runs on both Mac OS and Windows. I am puzzled by some of the dramatic apparent font size differences of specific Qt widgets, while other widgets display consistently (assuming no changes to code). Specifically, Qt widgets like; QDateTimeEdit, cells of QTableWidget ... seem to render extremely large under Windows and extremely small under Mac OS, while both being set to the same 8 point font-size in the Qt code. ?
And, conversely, widgets like QLabel, and item rows of QListWidget, have font-sizes that seem to render consistently in size across both OS platforms.
Any advice for my novice dev experience in Qt would be greatly appreciated.
Thank you,
David J.
-
Ok, I had some font inheritance discrepancies across my app for the main window + dialog window, etc. And this thread from another forum gave me some good insight on the best fonts for portability (i.e.: Verdana, Tahoma, Arial, etc.).
-
Hi,
A font size of 8 points is very small on Mac
QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont);
return a 9 point as minimum size on Mac:
QFont( ".Lucida Grande UI,9,-1,5,50,0,0,0,0,0" )Maybe you can use this fonction to get a more compatible small size font across platforms.
Another possibility is to use the general font :
QFontDatabase::systemFont(QFontDatabase::GeneralFont)
or simply QFont();and apply a small factor to its size.
That's what i'm using in my apps. -
Thanks for the suggestion. I will try out yours and more fonts. A little more detail; my confusion is where there are dramatic differences in the widget font sizes even on the same dialog + same font, only the OS changed.
For example, why would font "MS Shell Dlg 2, Point Size 8" (the Qt Creator default under Windows) set on a QDateTimeEdit widget look huge under Windows, and tiny under Mac... yet, the same font "MS Shell Dlg 2, Point Size 8" set on a QLabel, look fine on both OSs? (not tiny under Mac OS)
Another example; why would font "Segoe UI, Point Size 9" set on a QListWidget look fine on both Windows and Mac OS, yet the same "Segoe UI, Point Size 9" set on a QTableWidget look huge on Windows, and tiny on Mac OS?
Scratching my head on the rendering diffs between widget types...
Thanks for any insight!
-
Ok, I had some font inheritance discrepancies across my app for the main window + dialog window, etc. And this thread from another forum gave me some good insight on the best fonts for portability (i.e.: Verdana, Tahoma, Arial, etc.).