You are not logged in.

prazak

Beginner

  • "prazak" started this thread

Posts: 27

Location: seattle, USA

  • Send private message

1

Monday, August 13th 2007, 9:35pm

Multiple Monitor Woes: QDesktopWidget

YO,

My app uses 2 QMainWindows so as to get two icons down in the windows taskmanager. A second instance of QMainWindow gets created on request after the first starts up. The thing is, users often move the 1st main window to a second monitor after startup, but then when the 2nd QMainWindow is instanced, it shows on the 1st primary monitor instead of the expected 2nd, which is annoying.

I see QDesktopWidget allows me to gleen what monitor a widget is on, but not how to make a widget live on the second monitor.

If I make the second QMainWindow a child of the first, it loses the desirable taskmanager appearance.

Thanks for any multi-monitor tips.

prazak

Beginner

  • "prazak" started this thread

Posts: 27

Location: seattle, USA

  • Send private message

2

Monday, August 13th 2007, 10:43pm

RE: Multiple Monitor Woes: QDesktopWidget

I think I figured it out. The key is to account for the screen geometry of other screens when you move your widget.

For example:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
// what screen are we on?
const int screen = QApplication::desktop()->screenNumber(this);
const QRect availableRect(QApplication::desktop()->availableGeometry(screen));

// if we are not on the primary monitor, account for that
int extra = 0;
for (int ff = 0; ff < screen; ff++ )
   extra += QApplication::desktop()->screenGeometry(ff).width();
	
const int iXpos = availableRect.width()/2 - frameGeometry().width()/2;
const int iYpos = availableRect.height()/2 - frameGeometry().height()/2;
move(iXpos + extra, iYpos);