Центрирование окна приложения
#include <QtGui>
#include <QtWidgets>
...
#if defined(QT_VERSION) && (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) && (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
QDesktopWidget desktop;
QRect rect = desktop.availableGeometry(this);
#elif defined(QT_VERSION) && (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
QScreen *screen = QGuiApplication::primaryScreen();
QRect rect = screen->availableGeometry();
#elif !defined(QT_VERSION)
#error "Qt 5/6 framework not found!"
#endif
QPoint center = rect.center();
int x = center.x() - (width() / 2);
int y = center.y() - (height() / 2);
center.setX(x);
center.setY(y);
move(center);...