Example: Widget: Fix build below 5.14
Fixes: #54 Signed-off-by: Yuhang Zhao <2546789017@qq.com>
This commit is contained in:
parent
399b1cef1c
commit
3e09c0f9b8
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue