Example: Widget: Fix build below 5.14

Fixes: #54

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
This commit is contained in:
Yuhang Zhao 2021-03-24 11:15:58 +08:00
parent 399b1cef1c
commit 3e09c0f9b8
1 changed files with 4 additions and 0 deletions

View File

@ -43,7 +43,11 @@ Widget::~Widget() = default;
void Widget::moveToDesktopCenter()
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
const QSize ss = screen()->size();
#else
const QSize ss = QGuiApplication::primaryScreen()->size();
#endif
const int newX = (ss.width() - width()) / 2;
const int newY = (ss.height() - height()) / 2;
move(newX, newY);