Application window on Multi monitor screen and centre placement
-
Hello,
I've a QMainWindow, which is launched by another application.
The problem is, in a multimonitor setup, the application launching my QMainWindow, might reside on the 3rd screen, but my window will always launch on the first.
I worked around this in the following way...
@
QDesktopWidget *m = new QDesktopWidget();
QPoint p= QCursor::pos();
int r= m->screenNumber(p); //get the screennumber where the mouse is
QRect d=m->screenGeometry(r);
QPoint l = d.center(); //not the correct solution
mainWin->move(l); //move the window to that screen
mainWin->show(); //launch@
Now, how do I launch this window in the centre of the scree.
d.center()
is not the correct way, as the topleft of the window will launch from the centre point, so it will be obscured.Kindly advise.
-
Hi,
from the top of my head something like that:
@
QRect mainWinGeometry = mainWin->geometry();
mainWinGeomtry->moveCenter(l);
mainWin->setGeometry(mainWinGeometry);
@WARNING: untested
Hope it helps