From 311096b8ae5582581cf797a085f045da4bc61650 Mon Sep 17 00:00:00 2001 From: zcy <290198252@qq.com> Date: Tue, 8 Dec 2020 00:11:45 +0800 Subject: [PATCH] no message --- Qss.cpp | 2 +- Qss.h | 29 +++++++++++++++-------------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/Qss.cpp b/Qss.cpp index bb3dae4..92fcc2b 100644 --- a/Qss.cpp +++ b/Qss.cpp @@ -271,7 +271,7 @@ QssMainWindow::QssMainWindow(QWidget *parent/* = 0*/, Qt::WindowFlags flags/* = installEventFilter(this); mFrameRect = m_frame->geometry(); - m_rcNormal = this->parentWidget()->geometry(); + m_rcNormal = m_frame->geometry(); m_rcNormalCentral = this->geometry(); connect(this->titleBar(),SIGNAL( OnMaxOrRestore(bool )),this,SLOT(OnMaxOrRestore(bool))); diff --git a/Qss.h b/Qss.h index 0032701..322d9e8 100644 --- a/Qss.h +++ b/Qss.h @@ -11,10 +11,13 @@ #include #include #include + +#include "ui_qsstoast.h" +#ifdef __MINGW32__ #include "windows.h" #include "winuser.h" -#include "ui_qsstoast.h" - +#pragma comment(lib, "libuser32.a") +#endif class QPushButton; class QLabel; @@ -37,6 +40,8 @@ typedef enum{ }ReiszeActions ; + + #define DECLARE_RESIZE() \ void resize(int w, int h);void resize(const QSize &); void setFixedHeight(int w); \ void setFixedWidth(int w);void setFixedSize(int w, int h);void setFixedSize(const QSize &s); \ @@ -45,12 +50,13 @@ typedef enum{ void setMaximumSize(const QSize &);void setMaximumSize(int maxw, int maxh); \ void setMaximumHeight(int minh);void setMaximumWidth(int minw); +// 用宏强制覆盖的方法不使用了,因为QSSMainWindow本身已经在event事件内做处理,每个event都重写了,无需再去覆盖。 #define DEFINE_RESIZE(name)\ void Qss##name::resize(int w, int h){ m_sizeActions |= RA_Resize; float scale = cale; m_size = QSize(w, h);Q##name::resize(m_size.width() * scale, m_size.height() * scale);}\ void Qss##name::resize(const QSize & size){ m_sizeActions |= RA_Resize; float scale = cale;m_size = size;Q##name::resize(m_size * scale);}\ void Qss##name::setFixedHeight(int h){m_sizeActions |= RA_FixedHeight;float scale = cale;m_size.setHeight(h);Q##name::setFixedHeight(m_size.height() * scale);}\ void Qss##name::setFixedWidth(int w){m_sizeActions |= RA_FixedWidth;float scale = cale;m_size.setWidth(w);Q##name::setFixedWidth(m_size.width() * scale);}\ - void Qss##name::setFixedSize(int w, int h){m_sizeActions |= RA_FixedSize;float scale = cale; m_size = QSize(w, h); Q##name::setFixedSize(m_size.width() * scale, m_size.height() * scale);}\ + void Qss##name::setFixedSize(int w, int h){m_sizeActions |= RA_FixedSize;float scale = cale; m_size = QSize(w, h); this->m_frame->setFixedSize(m_size.width() * scale, m_size.height() * scale) ; }\ void Qss##name::setFixedSize(const QSize & size){m_sizeActions |= RA_FixedSize;float scale = cale; m_size = size; Q##name::setFixedSize(m_size * scale);}\ void Qss##name::setMinimumSize(const QSize & size){m_sizeActions |= RA_MinimumSize;float scale = cale;m_minimumSize = size; Q##name::setMinimumSize(m_minimumSize * scale);}\ void Qss##name::setMinimumSize(int w, int h){m_sizeActions |= RA_MinimumSize;float scale = cale; m_minimumSize = QSize(w, h); Q##name::setMinimumSize(m_minimumSize.width() * scale, m_minimumSize.height() * scale);}\ @@ -183,22 +189,17 @@ public: virtual bool nativeEventFilter(const QByteArray &eventType, void *message, long *) Q_DECL_OVERRIDE { MSG* pMsg = reinterpret_cast(message); - switch (pMsg->message) - { - case WM_DPICHANGED: + if(nullptr != pMsg){ + switch (pMsg->message) { - qDebug()<<"DPI CHANGED"; - /*DWORD dpi = LOWORD(pMsg->wParam); - //WId id = WINDOW_WINID; - //if (DPIHelper()->DPIChanged(dpi, id)) + case WM_DPICHANGED: { - ScaleChanged(DPIHelper()->GetDPIScale(id)); - RefrushSheet(this, id); - }*/ + qDebug()<<"DPI CHANGED"; + + } } } // TODO: filter out or modify msg struct here - // ... return false; } };