Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
How to prevent scaling of Qt app on different screen resolutions in windows as well as other machines??
I am a newbie to Qt, I read from Qt docs that Qt app are scalable depending on the screen resolution. But, is there any way i can prevent this? I do not want my app window to scale rather I want it to be of fixed height and fixed width on all screen resolutions. Appreciate your help towards this.
ODБOï last edited by ODБOï
Thanks for the reply. But, was going through the same page and read that "For games, you would typically want to create a game board that does not scale, so as not to provide an unfair advantage to players on larger screens." So I wanted to know how we can prevent scaling if i never want my Qt app window size to alter.
prex last edited by prex
If you want to fix the size of the complete main window, you can just define height and width of it. In addition, if you also define the max and min values, it will not be scaleable.
I saw few posts like https://www.qtcentre.org/threads/2233-QT4-Any-way-to-disable-window-resizing . But, none of them are working. If i change the resolution of the screen of the windows machine, the Qt app scales up according to the resolution.
Hi, and welcome!
I want it to be of fixed height and fixed width on all screen resolutions.
Could you please clarify: Do you want your app width to be a fixed number of pixels, or a fixed number of centimeters?
If i change the resolution of the screen of the windows machine, the Qt app scales up according to the resolution.
Do you mean that the board looks bigger on the same screen if you apply a lower resolution? If so, that is not what the article means by "scaling".
If that's not what you meant, please post your code to demonstrate your issue.
Hi, that is what exactly I meant. I want my app to be of fixed width and height in terms of pixels. I have kept the size as fixed. If I lower the resolution, the app window enlarges. But, I do not need it to appear bigger. Apprrciate your inputs to achieve this. Example can be as simple as having a push button in the app. Fix the size of app as well as size of push button to be fixed as follows may be. setFixedSize(600, 300); Then run the app in recommended resolution in my resolution settings to get the expected window sizes. Now, if I close the app window, lower the resolution of my machine in Windows and run the app. I can see that the app window appears big. I want it to be as small as it appeared in previous resolution settings. I am using windows 10.
I want my app to be of fixed width and height in terms of pixels.
First, you must realize:
- If you call
setFixedSize(600, 300), then Qt guarantees that your widget is always 600x300 pixels.
- When you change the screen's resolution, the size of each pixel changes.
- When you increase the screen's resolution, each pixel becomes smaller on the same screen.
- When you decrease the screen's resolution, each pixel becomse larger on the same screen.
- Your widget remains unchanged; it is always 600x300 pixels no matter what your screen's resolution is.
My next question is: Imagine that your app has 2 different users. User X displays your app on a 24" FHD monitor (1920x1080 pixels). User Y displays your app on a 55" FHD TV (also 1920x1080 pixels).
- What size (in centimeters or inches) should your 600x300 window be on the 24" monitor?
- What size (in centimeters or inches) should your 600x300 window be on the 55" TV?
- If you call
JonB last edited by JonB
I want it to be of fixed height and fixed width on all screen resolutions
As @JKSH has said. Correct me if I'm wrong, but, say, a mobile phone has a fair number of pixels resolution but in a much smaller area than on a monitor (must have much smaller physical pixels size). It's one thing to say "I will limit my app to 800 x 600 pixels on both", or similar, but quite another to say "I want my game running on a monitor to occupy the same 8cm x 6cm as it does on a cell phone", you will kill the monitor user's eyesight :)