ruomeng
deepin
2018-12-14 19:39 本帖最后由 ruomeng 于 2018-12-14 11:52 编辑
使用QT的方法使用QApplication::screen()获取QScreen然后查询devicePixelRatio
示例代码
#include
#include
#include
#include
int main(int argc, char *argv[]) {
QApplication app(argc, argv);
QWidget w;
QList desktop = QApplication::screens();
QLabel * label = new QLabel(&w);
QString str = "当前窗口的缩放值为: " + QString::number( desktop.at(0)->devicePixelRatio()) ;
label->setText(str);
label->adjustSize();
w.move(500, 300);
w.show();
return app.exec();
}
使用QT的方法使用QApplication::screen()获取QScreen然后查询devicePixelRatio
示例代码
#include
#include
#include
#include
int main(int argc, char *argv[]) {
QApplication app(argc, argv);
QWidget w;
QList desktop = QApplication::screens();
QLabel * label = new QLabel(&w);
QString str = "当前窗口的缩放值为: " + QString::number( desktop.at(0)->devicePixelRatio()) ;
label->setText(str);
label->adjustSize();
w.move(500, 300);
w.show();
return app.exec();
}
Reply Like 0 View the author


中文 

