Home > Fresh News > How to center a window on the screen

How to center a window on the screen

January 26th, 2011 Leave a comment Go to comments
#include <QStyle>
#include <QDesktopWidget>

window->setGeometry(QStyle::alignedRect(Qt::LeftToRight,
                                        Qt::AlignCenter,
                                        window->size(),
                                        qApp->desktop()->availableGeometry() ));

Qt wiki

  1. No comments yet.
  1. No trackbacks yet.
You must be logged in to post a comment.