3
我有一個QMainWindow
,它由另一個應用程序啓動。多監視器屏幕上的應用程序窗口和中心位置
問題是,在多監視器設置中,啓動我的QMainWindow
的應用程序可能駐留在第三個屏幕上,但我的窗口將始終在第一個屏幕上啓動。
我以下列方式工作圍繞這個...
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
現在,我該如何在屏幕中心推出這個窗口。 d.center()
不是正確的方法,因爲窗口的頂部將從中心點啓動,所以它會被遮擋。
請注意。
謝謝。這個技巧很好。 – user1173240 2013-05-14 09:37:37