Details
-
Bug
-
Resolution: Invalid
-
Not Evaluated
-
None
-
5.15
-
Centos7, macOS Monterey, windows 10
Description
#include "mainwindow.h" #include <QApplication> #include <QDebug> #include <QScreen> int main(int argc, char *argv[]) { for (int i=0; i< argc; i++) qDebug() << "main parameter:" << QString::fromLatin1(argv[i]); int scaleFactor; { QGuiApplication a(argc, argv); scaleFactor=QGuiApplication::screens()[0]->logicalDotsPerInch() / 96.0f; } qputenv("Q_SCALE_FACTOR", QByteArray::number(scaleFactor)); for (int i=0; i< argc; i++) qDebug() << "main parameter after QGuiApplication:" << QString::fromLatin1(argv[i]); QApplication a(argc, argv); return 0; }
I run the program with the parameter -platform=minimal
The result is: main parameter: "test123" main parameter: "-platform" main parameter: "minimal" main parameter after QGuiApplication: "test123"
As you can see there is no logs:
"main parameter after QGuiApplication: -platform"
"main parameter after QGuiApplication: minimal"
Why the parameters was removed?
I noticed that QCoreApplicationn doesn't do this.
The first QApplication call removes the "platform=minimal" parameter, so the second QApplication call tries to load the "xcb plugin" instead of "minimal plugin", which ends up with an error "qt.qpa.xcb: could not connect to display"
Is there a way to check the name of the plugin that was loaded the first time QApplication was run ?
Is there a better way to read the pixel density than creating a temporary QApplication object ?