View Full Version : About QMainWindow
bhs-ittech
31st August 2006, 10:12
Is there a simple way to center a QMainWindow object on the
users screen?
jacek
31st August 2006, 10:14
Just move() it there. You can use QDesktopWidget to get the desktop size.
jpn
31st August 2006, 10: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, 10: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);
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.