How to CenterScreen the Application?
-
Hi,
I am new to QT and developing an Application in QT, found it too exciting:-)
I just want to know how to start the application windows on the center of screen, tried a lot but couldn't get through.
-
Try this:
@QRect frect = frameGeometry();
frect.moveCenter(QDesktopWidget().availableGeometry().center());
move(frect.topLeft());@http://darkmind2007.blogspot.com/2009/10/qt-window-in-center-of-screen.html
Works for me and as far as I know there is no function in Qt which can center window so you can use this solution above.
-
[quote author="peppe" date="1295841691"]@
window->setGeometry(QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter, window->size(), qApp->desktop()->availableGeometry()));
@It's a common issue.[/quote]
Now you can point to this "wiki article":http://developer.qt.nokia.com/wiki/Center_a_Window_on_the_Screen in the future :-)
-
Thanks for the reply.
@Mazur.. It's not working. showing 'frameGeometry() not defined' and 'move not defined'.
@peppe.. it also shows error 'Invalid struct QStyle'
-
Thanks Volker.
It's working now:-)