Qt Windows高清DPI自适应分辨率缩放

windows实际分辨率, 1920x1080

显示窗体w大小:800x600


100缩放率:

关闭Qt::AA_EnableHighDpiScaling

ui->pushButton->size() QSize(114, 30)

"\\\\.\\DISPLAY1"

devicePixelRatio 1

geometry QRect(0,0 1920x1080)

virtualGeometry QRect(0,0 1920x1080)

size QSize(1920, 1080)

virtualSize QSize(1920, 1080)

logicalDotsPerInch 96

scale: 1


开启Qt::AA_EnableHighDpiScaling

ui->pushButton->size() QSize(114, 30)

"\\\\.\\DISPLAY1"

devicePixelRatio 1

geometry QRect(0,0 1920x1080)

virtualGeometry QRect(0,0 1920x1080)

size QSize(1920, 1080)

virtualSize QSize(1920, 1080)

logicalDotsPerInch 96

scale: 1


125缩放率:

关闭Qt::AA_EnableHighDpiScaling


ui->pushButton->size() QSize(114, 30)

"\\\\.\\DISPLAY1"

devicePixelRatio 1

geometry QRect(0,0 1920x1080)

virtualGeometry QRect(0,0 1920x1080)

size QSize(1920, 1080)

virtualSize QSize(1920, 1080)

logicalDotsPerInch 120

scale: 1.25

w.size() QSize(800, 600)


开启Qt::AA_EnableHighDpiScaling

ui->pushButton->size() QSize(114, 30)

"\\\\.\\DISPLAY1"

devicePixelRatio 1

geometry QRect(0,0 1920x1080)

virtualGeometry QRect(0,0 1920x1080)

size QSize(1920, 1080)

virtualSize QSize(1920, 1080)

logicalDotsPerInch 120

scale: 1.25

w.size() QSize(800, 600)


150缩放率:

关闭Qt::AA_EnableHighDpiScaling

ui->pushButton->size() QSize(114, 30)

devicePixelRatio 1

geometry QRect(0,0 1920x1080)

virtualGeometry QRect(0,0 1920x1080)

size QSize(1920, 1080)

virtualSize QSize(1920, 1080)

logicalDotsPerInch 144

scale: 1.5

开启Qt::AA_EnableHighDpiScaling

ui->pushButton->size() QSize(114, 30)

devicePixelRatio 2

geometry QRect(0,0 960x540)

virtualGeometry QRect(0,0 960x540)

size QSize(960, 540)

virtualSize QSize(960, 540)

logicalDotsPerInch 96

scale: 1

看来会按照 devicePixelRatio 去把屏幕大小做了缩小


175缩放率:

关闭Qt::AA_EnableHighDpiScaling

ui->pushButton->size() QSize(114, 30)

"\\\\.\\DISPLAY1"

devicePixelRatio 1

geometry QRect(0,0 1920x1080)

virtualGeometry QRect(0,0 1920x1080)

size QSize(1920, 1080)

virtualSize QSize(1920, 1080)

logicalDotsPerInch 168

scale: 1.75


开启Qt::AA_EnableHighDpiScaling

ui->pushButton->size() QSize(114, 30)

"\\\\.\\DISPLAY1"

devicePixelRatio 2

geometry QRect(0,0 960x540)

virtualGeometry QRect(0,0 960x540)

size QSize(960, 540)

virtualSize QSize(960, 540)

logicalDotsPerInch 96

scale: 1


下面这种方法待尝试

image

使用qt.conf,在资源qrc里添加,qt/etc/qt.conf, qt.conf文件内容为:

[Platforms][Platforms]
WindowsArguments = dpiawareness=0


https://blog.csdn.net/startl/article/details/105862817


https://doc.qt.io/qt-5/highdpi.html


https://doc.qt.io/qt-6/highdpi.html

Lower-level graphics drawing (such as OpenGL code) need to be high-DPI aware, but can use cross platform Qt APIs to learn about the platform's display resolutions.


但是dpi aware情况下,控件显示异常怎么解决?

posted on   katago  阅读(1531)  评论(0编辑  收藏  举报

< 2025年1月 >
29 30 31 1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31 1
2 3 4 5 6 7 8

统计

点击右上角即可分享
微信分享提示