If you're really sold on using the Designer, perhaps consider updating Stylesheets programmatically. This is a really hacky fix I implemented in an app I had to deploy across multiple platforms. This would mean using px
measurements for everything, as it is the only widely supported measurement.
As you may know, Qt fonts do not support 'screen-size' relative em
units:
From Qt5 documentation: https://doc.qt.io/qt-5/stylesheet-reference.html
Qt is limited to font sizes in pt and px and any other size must be in px, em or ex.
Whichever monitor and its specifications you've developed a UI you are happy with will become the standard for your application. In the constructor of your windows, you can calculate a scale factor as the new device's DPI divided by the 'standard DPI' that you know your application looks good on. From there, you simply would need to multiply your widgets/fonts stylesheets by that scale factor. It may sound cumbersome (and it definitely is), but this would mean iterating through the QString returned by ui->myWidget->getStyleSheet() and scaling all number instances preceding a px
substring.
This worked for me in scaling up/down fonts and widget sizes, but with obviously added overhead. I too also really like the simplicity of using the Designer but, afaik, creating scalable UI's remains difficult in Designer. Making the switch to programmatically designing UI's ended up replacing my hacky fix for my application.
Note: It is also important to look out for what fonts you're using. If your font is not a System-supported font, the px
value will have unexpected behaviour, since a default font will replace it.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…