Solved QT and opencv dualmonitor
-
First thing to do is to check the number of screens returns by
qApp->screens()
. Depending on your configuration, a dual monitor setup can be interpreted as only one big screen by the OS. -
Oh yes with that
qDebug() << qApp->screens(); qDebug() << QApplication::desktop()->screenCount();
result in consol is
(QScreen(0x14acd808) ) 1
I executed code in windows 8 on laptop with second screen connected and I display my laptop in second screen but why detected only one screen?
I can't to do dual monitors?
Thanks for you help
My OS detebut
-
Are you mirroring your desktop ?
-
@SGaist said:
Are you mirroring your desktop
I just connect with vga cable, i think by default window choice mirroring desktop, i have to duplicate? my situation is http://windows.microsoft.com/en-us/windows-vista/understanding-multiple-monitors My situation is Mirrored desktop display
-
Then if you are mirroring you have one logical screen.
-
ok thanks, now I change mode of display in windows and second screen is detected:
qDebug() << "Number of screens:" << QGuiApplication::screens().size(); qDebug() << "Primary screen:" << QGuiApplication::primaryScreen()->name(); Number of screens: 2 Primary screen: "\\.\DISPLAY1"
So i try to display a widget with that
QWidget * widget = new QWidget(); widget->show(); widget->windowHandle()->setScreen(qApp->screens()[1]); widget->showFullScreen();
I d'ont error my project compil scuessfully but my widget it's not display in nothing screen.
How i can to do this? thanks for you helping -
Rather something like:
MyWidget widget; QDesktopWidget *desktop = QApplication::desktop(); QRect geometry = desktop->screenGeometry(1); QRect widgetGeometry = widget.geometry(); widgetRegion.moveCenter(geometry.center()); w.setGeometry(wRegion);
-
Don't run nothing is diplay my code is:
qDebug() << "Number of screens:" << QGuiApplication::screens().size(); QWidget widget ; QDesktopWidget *desktop = QApplication::desktop(); QRect geometry = desktop->screenGeometry(1); QRect widgetGeometry = widget.geometry(); widgetGeometry.moveCenter(geometry.center()); widget.setGeometry(widgetGeometry); return 0;
Return compilation :
Starting C:\Users\user\Documents\build-Double_video-Desktop_Qt_5_4_2_MinGW_32bit2-Debug\debug\Double_video.exe...
Number of screens: 2
C:\Users\user\Documents\build-Double_video-Desktop_Qt_5_4_2_MinGW_32bit2-Debug\debug\Double_video.exe exited with code 0thanks for you helping.
-
If that's your main application then it's normal that nothing is shown. You don't run Qt's event loop. You just create the widget, modify its geometry and return 0 which just ends the application. You need to replace that by
return app.exec();
provided that your QApplication instance is calledapp
. -
Thanks you very much it's work,
My code for other persons with same problemDisplay two widget one in first monitor and other in second monitor.
QWidget widget ; QDesktopWidget *desktop = QApplication::desktop(); QRect geometry = desktop->screenGeometry(1); QRect widgetGeometry = widget.geometry(); widgetGeometry.moveCenter(geometry.center()); widget.setGeometry(widgetGeometry); widget.show(); QWidget widget2 ; QRect geometry2 = desktop->screenGeometry(0); QRect widgetGeometry2 = widget2.geometry(); widgetGeometry2.moveCenter(geometry2.center()); widget2.setGeometry(widgetGeometry2); widget2.setWindowTitle("test"); widget2.show(); return app.exec();