From 7880fbfb16102a5e52ab5809a1749e2a1645f8b8 Mon Sep 17 00:00:00 2001 From: Yuhang Zhao <2546789017@qq.com> Date: Sun, 11 Oct 2020 10:36:20 +0800 Subject: [PATCH] Update. Signed-off-by: Yuhang Zhao <2546789017@qq.com> --- framelesshelper_windows.pro | 2 +- winnativeeventfilter.cpp | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/framelesshelper_windows.pro b/framelesshelper_windows.pro index 3f920e7..8557871 100644 --- a/framelesshelper_windows.pro +++ b/framelesshelper_windows.pro @@ -17,7 +17,7 @@ DEFINES += \ FRAMELESSHELPER_STATIC LINK_TO_SYSTEM_DLL { DEFINES += WNEF_LINK_SYSLIB - LIBS += -luser32 -lgdi32 -ldwmapi -lshcore + LIBS += -luser32 -lgdi32 -ldwmapi -lshcore -ld2d1 } CONFIG -= embed_manifest_exe RC_FILE = framelesshelper_windows.rc diff --git a/winnativeeventfilter.cpp b/winnativeeventfilter.cpp index 623e2b7..799050c 100644 --- a/winnativeeventfilter.cpp +++ b/winnativeeventfilter.cpp @@ -113,7 +113,7 @@ Q_DECLARE_METATYPE(QMargins) #else #define WNEF_RESOLVE_ERROR(funcName) \ if (!m_lp##funcName) { \ - qCritical().noquote() << "Failed to resolve symbol" << #funcName; \ + qFatal("Failed to resolve symbol" #funcName); \ } #endif #endif @@ -944,13 +944,17 @@ HWND getHWNDFromQObject(QObject *object) { Q_ASSERT(object); WId wid = 0; + if (object->isWindowType()) { + wid = qobject_cast(object)->winId(); + } #ifdef QT_WIDGETS_LIB - if (object->isWidgetType()) { + else if (object->isWidgetType()) { wid = qobject_cast(object)->winId(); } #endif - if (object->isWindowType()) { - wid = qobject_cast(object)->winId(); + else { + qFatal( + "Can't acquire the window handle: only top level QWidgets and QWindows are accepted."); } return reinterpret_cast(wid); }