no message

qt6
zcy 2020-12-08 00:11:45 +08:00
parent 44177aa13c
commit 311096b8ae
2 changed files with 16 additions and 15 deletions

View File

@ -271,7 +271,7 @@ QssMainWindow::QssMainWindow(QWidget *parent/* = 0*/, Qt::WindowFlags flags/* =
installEventFilter(this); installEventFilter(this);
mFrameRect = m_frame->geometry(); mFrameRect = m_frame->geometry();
m_rcNormal = this->parentWidget()->geometry(); m_rcNormal = m_frame->geometry();
m_rcNormalCentral = this->geometry(); m_rcNormalCentral = this->geometry();
connect(this->titleBar(),SIGNAL( OnMaxOrRestore(bool )),this,SLOT(OnMaxOrRestore(bool))); connect(this->titleBar(),SIGNAL( OnMaxOrRestore(bool )),this,SLOT(OnMaxOrRestore(bool)));

23
Qss.h
View File

@ -11,10 +11,13 @@
#include <QPushButton> #include <QPushButton>
#include <QAbstractNativeEventFilter> #include <QAbstractNativeEventFilter>
#include <QDebug> #include <QDebug>
#include "ui_qsstoast.h"
#ifdef __MINGW32__
#include "windows.h" #include "windows.h"
#include "winuser.h" #include "winuser.h"
#include "ui_qsstoast.h" #pragma comment(lib, "libuser32.a")
#endif
class QPushButton; class QPushButton;
class QLabel; class QLabel;
@ -37,6 +40,8 @@ typedef enum{
}ReiszeActions ; }ReiszeActions ;
#define DECLARE_RESIZE() \ #define DECLARE_RESIZE() \
void resize(int w, int h);void resize(const QSize &); void setFixedHeight(int w); \ 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); \ 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 setMaximumSize(const QSize &);void setMaximumSize(int maxw, int maxh); \
void setMaximumHeight(int minh);void setMaximumWidth(int minw); void setMaximumHeight(int minh);void setMaximumWidth(int minw);
// 用宏强制覆盖的方法不使用了因为QSSMainWindow本身已经在event事件内做处理每个event都重写了无需再去覆盖。
#define DEFINE_RESIZE(name)\ #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(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::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::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::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::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(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);}\ 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 virtual bool nativeEventFilter(const QByteArray &eventType, void *message, long *) Q_DECL_OVERRIDE
{ {
MSG* pMsg = reinterpret_cast<MSG*>(message); MSG* pMsg = reinterpret_cast<MSG*>(message);
if(nullptr != pMsg){
switch (pMsg->message) switch (pMsg->message)
{ {
case WM_DPICHANGED: case WM_DPICHANGED:
{ {
qDebug()<<"DPI CHANGED"; qDebug()<<"DPI CHANGED";
/*DWORD dpi = LOWORD(pMsg->wParam);
//WId id = WINDOW_WINID; }
//if (DPIHelper()->DPIChanged(dpi, id))
{
ScaleChanged(DPIHelper()->GetDPIScale(id));
RefrushSheet(this, id);
}*/
} }
} }
// TODO: filter out or modify msg struct here // TODO: filter out or modify msg struct here
// ...
return false; return false;
} }
}; };