QScreen of multi-monitor cannot be returned.
-
I'm developing a Qt app on dual monitors and using 6.2.
QApplication screens() always returns a single Screen value.
It has the geometry value of the secondary monitor and does not get the information of the primary monitor.#include "mainwindow.h" #include <QApplication> #include <QScreen> int main(int argc, char *argv[]) { QApplication a(argc, argv); MainWindow w; w.show(); qDebug().noquote() << "Screen size: : " << QApplication::screens().size(); foreach(QScreen *screen, QApplication::screens()) { qDebug().noquote() << "Name : " << screen->name(); qDebug().noquote() << "DevicePixelRatio : " << screen->devicePixelRatio(); qDebug().noquote() << "Width : " << screen->geometry().width(); qDebug().noquote() << "Height : " << screen->geometry().height(); qDebug().noquote() << "Size : " << screen->geometry().size(); qDebug().noquote() << "Geom : " << screen->geometry(); } qDebug().noquote() << "Primary screen Geom : " << QApplication::primaryScreen()->geometry(); return a.exec(); }
result
[15704] Screen size: : 1
[15704] Name : DELL U2722D
[15704] DevicePixelRatio : 1
[15704] Width : 2560
[15704] Height : 1440
[15704] Size : QSize(2560, 1440)
[15704] Geom : QRect(2560,0 2560x1440)
[15704] Primary screen Geom : QRect(2560,0 2560x1440)On the other computer, the QScreen on the dual monitor returns normally without any problems.
Any solution?
-
Hi,
Are they both desktop machines ?
What are the differences between them ? -
Maybe a silly question, but are the monitors in extend or duplicate mode? Duplicate would return a single entry.