Style sheets / Qt Designer support for high dpi sc

2019-01-22 21:34发布

Today I have ported my application from Qt5.5 to Qt5.6RC. Running it on my high dpi screen the widgets appeared tiny. After reading this and setting QT_AUTO_SCREEN_SCALE_FACTOR to "1" at least it is usable again.

However they say:

In the longer term, the application should be adapted to run unmodified:

1) Always use the qreal versions of the QPainter drawing API.
2) Size windows and dialogs in relation to the screen size.
3) Replace hard-coded sizes in layouts and drawing code by values calculated from font metrics or screen size.

Not all style sheet attributes support em (".. from font metrics"). No idea how I would use "screen size" relative in style sheets. Also Qt Designer only supports px in many places, like shown below.

icon size

Considered I do not want to give up designer and stylesheets, what are my options to create genuine Qt hires applications?


Related (but no answer to my question)

1条回答
迷人小祖宗
2楼-- · 2019-01-22 22:25

not sure it will help since I never really used designer for my qt applications, but I guess at some point you will be forced to do like some websites and have some dedicated qss files based on your screen resolution.

I think it's quite easy to do that in CSS3, not sure what is supported in qss. I found this post explaining how to retrieve the screen resolution of the main display: QT getting the screen resolution without the extended monitor

For the "1em" question, even if you didn't set any font size, one will be pick by default, so 1em will means 100% of your default font size I guess.

Regards.

查看更多
登录 后发表回答