Font Size (DPI)



  • I set my application's main window to a fixed size, by setting the minimum and maximum size the same. The only problem that I am worried about is if the user changes the font size / DPI in the control panel. Then, not all of the text fits on the window, and the text on the controls doesn't look centered. What should I do about this problem? My idea was to check the user's font size, and if it is not 100%, then set it to 100%, and when the application closes, set it back to the original value. Is there a way to do this in Qt? Or, is there a better solution?



  • The better solution is obviously to make sure your application can be resized (use the layout system. It's extremely useful). Other options include scrollbars or auto-resizing as you suggest. In the latter case, I think you should look for changeEvent(), but I'm not entirely sure of that.



  • [quote author="szh1" date="1288827273"]... The only problem that I am worried about is if the user changes the font size / DPI in the control panel. ... My idea was to check the user's font size, and if it is not 100%, ...[/quote]

    Which control panel are you referring to here?

    You are setting a fixed size to your main window, but allowing the user to change the font size. And if the user changes the font size, in that case, you again want to reset the font size to 100%? In that case why don't you set a fixed font size upfront and not allow the user to change it i the first place?

    I'd refer to how apps like MS Word handles this scenario ... the pages are fixed, the font sizes can be varied and implement the functionality in the same way.



  • I mean the Windows Control Panel under "Display". The user can change how big text is displayed in all applications that run on their system ("DPI"). The default is 100%, meaning "9 point Segoe UI at 96 pixels per inch."

    If the user increases the value, then I have a problem.



  • "You can find more about DPI here":http://en.wiktionary.org/wiki/dots_per_inch


  • Moderators

    I would keep the font size the user has set up and not mess with it. The user usually has some reason to make the fonts bigger, including bad eye sight, etc. You are going to make the application unusable for that user if you force the fonts back to a smaller size.

    The best solution is not to hard code the window size and to use layouts instead.



  • Okay, I guess I'll have to use layouts. Thanks for the help.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.