Fix Qt5 and Qt6 build.

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
This commit is contained in:
Yuhang Zhao 2020-11-07 00:29:36 +08:00
parent fd3fb7deda
commit 1bf0d59efa
2 changed files with 8 additions and 0 deletions

View File

@ -253,7 +253,11 @@ void Widget::setupUi()
QFont font1; QFont font1;
font1.setPointSize(15); font1.setPointSize(15);
font1.setBold(true); font1.setBold(true);
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
font1.setWeight(QFont::Bold);
#else
font1.setWeight(75); font1.setWeight(75);
#endif
customizeTitleBarCB->setFont(font1); customizeTitleBarCB->setFont(font1);
verticalLayout->addWidget(customizeTitleBarCB); verticalLayout->addWidget(customizeTitleBarCB);
preserveWindowFrameCB = new QCheckBox(controlPanelWidget); preserveWindowFrameCB = new QCheckBox(controlPanelWidget);

View File

@ -1833,7 +1833,11 @@ bool WinNativeEventFilter::nativeEventFilter(const QByteArray &eventType,
#ifdef QT_WIDGETS_LIB #ifdef QT_WIDGETS_LIB
const auto widget = qobject_cast<QWidget *>(object); const auto widget = qobject_cast<QWidget *>(object);
if (widget) { if (widget) {
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
const QPointF pos = widget->mapToGlobal(QPointF{0, 0}); const QPointF pos = widget->mapToGlobal(QPointF{0, 0});
#else
const QPoint pos = widget->mapToGlobal(QPoint{0, 0});
#endif
if (QRectF(pos.x() * dpr, if (QRectF(pos.x() * dpr,
pos.y() * dpr, pos.y() * dpr,
widget->width() * dpr, widget->width() * dpr,