PDA

View Full Version : About QMainWindow



bhs-ittech
31st August 2006, 11:12
Is there a simple way to center a QMainWindow object on the
users screen?

jacek
31st August 2006, 11:14
Just move() it there. You can use QDesktopWidget to get the desktop size.

jpn
31st August 2006, 11:19
Check thread: set QMainWindow in the center of my desktop (http://www.qtcentre.org/forum/f-newbie-4/t-set-qmainwindow-in-the-center-of-my-desktop-3399.html)

bhs-ittech
31st August 2006, 11:42
sorry for not seaching the other threads.

Thanks for the pointer though.

I found a simple working solution:

QMainWindow *w = new QMainWindow;
w->show();
QRect ct = w->geometry();
ct.moveCenter(QApplication::desktop->availableGeometry().center());
w->setGeometry(ct);