PDA

View Full Version : Display QDialog in the monitor in which the application is launched



gokul149
8th March 2012, 18:37
I've multiple monitors attached to my computer. I want QDialog to be displayed in the monitor from which I launch the executable. Currently the QDialog is displayed randomly in any monitor(mostly in primary monitor).
Is this possible to do?

Lykurg
8th March 2012, 20:21
You can save the number of the monitor at start time, and then, when displaying the dialog, just ensure it is shown there.

gokul149
9th March 2012, 03:44
My code goes like this..


QDesktopWidget * d = QApplication::desktop ();
QRect r = d->screenGeometry(this);
In the QRect I'm getting the monitor size from which the executable is launched. But when the QDialog is displayed, sometimes it gets displayed in other screens. How to ensure that QDialog gets displayed in the same monitor.

Lesiok
9th March 2012, 07:10
Read about QDesktopWidget

Lykurg
9th March 2012, 09:48
QDesktopWidget::screenNumber(), QDesktopWidget::screenGeometry() and QWidget::setGeometry().