Not sure if you know this already or not.QDesktopWidget * QApplication::desktop () [static]
Returns the desktop widget (also called the root window).
Note that the desktop may be composed of multiple screens, so it would be incorrect, for example, to attempt to center some widget in the desktop's geometry. QDesktopWidget has various functions for obtaining useful geometries upon the desktop, such as QDesktopWidget::screenGeometry() and QDesktopWidget::availableGeometry().
Centering Screen
-
- ZSNES Developer
- Posts: 3904
- Joined: Tue Jul 27, 2004 10:54 pm
- Location: Solar powered park bench
- Contact:
Centering Screen
byuu, see this:
May 9 2007 - NSRT 3.4, now with lots of hashing and even more accurate information! Go download it.
_____________
Insane Coding
_____________
Insane Coding
Yeah, but thanks anyway.
Code: Select all
//show specified window in the center of the screen.
void Utility::showCentered(QWidget *window) {
QRect deskRect = QApplication::desktop()->availableGeometry(window);
...
window->move(
deskRect.center().x() - (window->frameSize().width() / 2),
deskRect.center().y() - (window->frameSize().height() / 2)
);