Qt 获取屏幕DPI
程序员文章站
2024-03-22 19:33:40
...
使用到的类QScreen;
window DPI可调范围为125%--250%和硬件有关系;
/96的目的是将int转成 1.0/1.25/1.5
double nn = QApplication::primaryScreen()->logicalDotsPerInch() / 96;
QList<QScreen*> listScreen = QGuiApplication::screens();
if (listScreen[0]) {
connect(listScreen[0], &QScreen::availableGeometryChanged, this, &screen::slot_availableGeometryChanged);
connect(listScreen[0], &QScreen::physicalDotsPerInchChanged, this, &screen::slot_physicalDotsPerInchChanged);
connect(listScreen[0], &QScreen::logicalDotsPerInchChanged, this, &screen::slot_logicalDotsPerInchChanged);
connect(listScreen[0], &QScreen::virtualGeometryChanged, this, &screen::slot_virtualGeometryChanged);
connect(listScreen[0], &QScreen::physicalSizeChanged, this, &screen::slot_physicalSizeChanged);
}