QT5.5 scaling high definition screens
using PyQT5/QT5.5, I wrote - as my first attempt with QT - a little app which runs fine on Win7, but on my Win8 laptop with a high-def screen the main window as well as some widgets are way too small (on the laptop I've set windows scaling to 200%). For composing the gui I use Qt Designer 5.5.0. I've read the docs multiple times as well as scanned the web, but I don't get it.
The issue seems to happen whenever there are explicit size values specified in QtDesigner, e.g. for getting a shorter Button than what the layout would normally do, or the MainWindow's size geometry. These seem to be interpreted as px and are not scaled when running.
I also have issues when I do my own painting, the painted objects are positioned incorrectly, obviously because I specify their position using e.g. move() with numbers.
How would I set Widget sizes in QTDesigner, and draw paintings, in a way that they would render fine on both the normal and high-def screen?
As mentioned, from the docs I didn't got it, sorry if the answer would be obvious.
Hi and welcome to devnet,
You can find here information about High DPI handling
Hope it helps
many thanks for the response
this page I know very well but unfortunately I can't extract any useful info, in terms of e.g. actual code, from it. E.g. how could I, using the QtDesigner, ensure that all widgets are using the qreal QPainter and replace all hardcoded sizes by something derived from some other metrics? Adding this in by hand for all widgets looks very daunting to me, and somewhat brute force, I would think that there should be a smarter way.
(e.g. I would have thought that all given pixel sizes are device independent pixels and thus scaled by Qt/OS, but that seems not to be the case).
Aren't you using layouts for your widgets ?
yes, I do use layouts, but I'm not sure it's of relevance
e.g., as said, the size of the main window itself at startup - for which in my understanding there is no layout since its the root widget of everything - is also displayed too small on a high-def screen!
the main window size I think is determined by the size in QtDesigner, and then coded into the ui file (or derived py file). On normal screens the window is sized as expected, on high-def screens it is also sized correctly in terms of pixel numbers, but here that's not what one wants as it's then way to small
So, how could one get the main window to be sized appropriately?
Did you start your application with QT_DEVICE_PIXEL_RATIO set to two ?