From 348df0114a5d1934b4944bca86640093f1fe4d39 Mon Sep 17 00:00:00 2001 From: Simon Quigley Date: Sat, 12 Jan 2019 20:11:03 -0600 Subject: [PATCH] Center the window on the screen. --- main.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/main.cpp b/main.cpp index 2d24a7e..b2d93d3 100644 --- a/main.cpp +++ b/main.cpp @@ -15,11 +15,22 @@ #include "mainwindow.h" #include +#include +#include +#include int main(int argc, char *argv[]) { QApplication app(argc, argv); MainWindow w; + w.setGeometry( + QStyle::alignedRect( + Qt::LeftToRight, + Qt::AlignCenter, + w.size(), + QGuiApplication::screens().first()->geometry() + ) + ); w.show(); return app.exec();