Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.15.2
-
None
-
-
Windows
Description
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
I use this code to set auto scaling, but when I use a QLabel and setWordWrap to true, the dialog will have a positon error when moved between screens with diffrent dpi! How to solved this problem?
// main.cpp #include <QApplication> #include <QDialog> #include <QLabel> #include <QVBoxLayout> int main(int argc, char *argv[]) { QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough); QApplication a(argc, argv); QDialog* dlg = new QDialog(); dlg->setFixedSize(400, 197); QVBoxLayout* mainLayout = new QVBoxLayout(dlg); QLabel* content = new QLabel(dlg); content->setWordWrap(true); content->setText("test test test test test test test test test test test test test test test test test test test test"); mainLayout->addWidget(content); dlg->show(); return a.exec(); }
This is a example, you can create a Qt project with QtCreator, and replace the main.cpp with this.