PDA

View Full Version : Disable text size auto-scaling



QMAsker
23rd April 2019, 22:51
Hello,

I have Qt Widget application and on some computers the text size is scaled automatically and it looks awful (not same, some labels too large, some labels too small). How can I disable it?
13090

Thanks!

d_stranz
24th April 2019, 00:46
If the OS is Windows 7 or 10 and the user has turned on text scaling in the Display settings, there probably isn't much you can do about it. This will affect all text, everywhere, though.

In the case of the text you have selected in the table, if your model's flags for this item allow editing, this font is probably instantiated by the QLineEdit delegate that is created when the cell is open for editing. For this, you can implement handling for the Qt:: FontRole in your model's data() method to return an appropriate font. The default font looks like it scales so as much of the cell text as possible can fit into the edit widget. If you don't want this, you can return the QFont of the table itself.

If you want a uniform font for everything in the widget you have posted, then you can set a QFont for that widget. All children of the QWidget will inherit that font. I usually this in Qt Designer when I lay out a composite widget. If you want all widgets in the app to inherit the same font, you can set the font at the app level (QCoreApplication::setFont()) before any widgets are created.