PDA

View Full Version : Question about screen resolution, dpi and font size



pixaeiro
13th April 2016, 05:01
Hello,

I am developing an application using Qt 5.3, and I have created most of the widgets using Qt Designer, which means, all widgets were designed with pixel accuracy.

All is fine and good in regular monitors, however, I have received a report from a user who has a high display monitor (2560x1440), in which the fonts are super large and all the layouts and buttons are pushed beyond their designed areas.

This is a screen shot of how the application looks in my 1920x1080 monitor:

http://i.imgur.com/DQpDcMi.png

And here is how it looks in a the 2560x1440 monitor:

http://i.imgur.com/H2EQPqv.jpg

My questions are:

- Why are the fonts so large? Is there a way to tell Qt to ignore the high dpi and use the fonts shown normally at 96 dpi?

- Is there a way to simulate this issue in my PC so that I can properly test and fix it?

- Is it possible to design the widgets in Qt Designer using a font size relative value?

Thank you!

d_stranz
13th April 2016, 16:50
Your image links don't work in Firefox. Why didn't you simply upload the images to the forum? There's even an "Insert Image" icon to do that...

However, I think I know what you mean. I use a 4K monitor (3840 x 2160). Normal Windows fonts are too small for me to read easily, so I used Windows "Customize your display" settings to increase the font size to 125% of normal. I noticed that some of my Qt apps did not react to this change properly, possibly those running with Qt 5.4, and especially those where I had designed GUI elements with fixed maximum sizes.

Ask your user if that is what he has done. You can simulate it (in Windows, anyway) using Settings->Display and increasing the text size. My fix was to either remove the size restrictions on labels, pushbuttons, etc. or to increase them so the text would fit when viewed on my screen. With any new GUIs, I use layouts wherever possible, and give them room to grow if necessary by adding horizontal or vertical stretch elements. In Qt 5.5 at least, I haven't noticed any further problems.

pixaeiro
13th April 2016, 18:12
Thanks d_stranz.

I didn't upload the images to the forum because it didn't allow me, I got a message saying the image was too large. I am testing in a different computer with Firefox and the links open an imgur page with the image, maybe you are blocking imgur in your Firefox.

I have done tests with Customize your dispaly and the Change the size of text, apps, and other items slider, and this setting scales the whole screen, and the scale is uniform, not just the fonts (like if you were resizing in Photoshop). My application has a ruler and some other items that I can measure in the screenshots, and they are the same size in both the 2560x1440 and 1920x1080 screenshots.

Is there a way in Qt to force it to use the same font everywhere?

Thank you!

ars
13th April 2016, 19:37
Hello,

I had the same problem using a 4k monitor and Qt 5.5 under Windows 10. As a temporary workaround I installed a file qt.conf into the application binary folder with following content:

[Platforms]
WindowsArguments = dpiawareness=0
With this setting Windows scales the whole application (fonts + graphics). Drawback of this approach: the fonts do not look as crisp as possible, but it is acceptable for scalings of 125-150%.

Qt 5.6 should provide better dpi awareness. I tried it a few months ago with a Qt 5.6 beta version and without installing the qt.conf file. The result was better than with version 5.5, but still not perfect. Hopefully it has improved for the released version, but I have not checked it up to now.

Best regards
ars

pixaeiro
13th April 2016, 20:24
Thank you ars.
I have asked the user to test this solution, I'll post here his response.