From e02dd2b8c525e48c4782a9ded7b38f5840bdd555 Mon Sep 17 00:00:00 2001 From: Konstantinos Sideris Date: Sat, 15 Apr 2017 17:23:35 +0300 Subject: [PATCH] Move the main window to the center --- .gitignore | 2 +- src/main.cc | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 81549ebb..ff385780 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ build tags +.clang_complete # C++ objects and libs @@ -44,4 +45,3 @@ CMakeCache.txt CMakeFiles cmake_install.cmake install_manifest.txt - diff --git a/src/main.cc b/src/main.cc index 9ef7ffd7..d7cb88b3 100644 --- a/src/main.cc +++ b/src/main.cc @@ -16,6 +16,7 @@ */ #include +#include #include #include "MainWindow.h" @@ -42,6 +43,13 @@ int main(int argc, char *argv[]) app.setFont(font); MainWindow w; + + // Move the MainWindow to the center + QRect screenGeometry = QApplication::desktop()->screenGeometry(); + int x = (screenGeometry.width() - w.width()) / 2; + int y = (screenGeometry.height() - w.height()) / 2; + + w.move(x, y); w.show(); return app.exec();