qt_demoe/framelesswidget/framelesswidget2.h

48 lines
1.0 KiB
C
Raw Normal View History

2021-05-15 11:10:30 +00:00
#ifndef FRAMELESSWIDGET2_H
#define FRAMELESSWIDGET2_H
#include <QWidget>
#ifdef quc
class Q_DECL_EXPORT FramelessWidget2 : public QWidget
#else
class FramelessWidget2 : public QWidget
#endif
{
Q_OBJECT
public:
explicit FramelessWidget2(QWidget *parent = 0);
protected:
bool eventFilter(QObject *watched, QEvent *event);
2021-07-05 09:56:20 +00:00
//拦截系统事件用于修复系统休眠后唤醒程序的BUG
#if (QT_VERSION >= QT_VERSION_CHECK(6,0,0))
bool nativeEvent(const QByteArray &eventType, void *message, qintptr *result);
#else
2021-05-15 11:10:30 +00:00
bool nativeEvent(const QByteArray &eventType, void *message, long *result);
2021-07-05 09:56:20 +00:00
#endif
//Qt4的写法
#if (QT_VERSION < QT_VERSION_CHECK(5,0,0))
2021-05-15 11:10:30 +00:00
#ifdef Q_OS_WIN
bool winEvent(MSG *message, long *result);
#endif
2021-07-05 09:56:20 +00:00
#endif
2021-05-15 11:10:30 +00:00
private:
2021-07-05 09:56:20 +00:00
//边距+可移动+可拉伸
2021-05-15 11:10:30 +00:00
int padding;
2021-07-05 09:56:20 +00:00
bool moveEnable;
bool resizeEnable;
public:
//设置边距+可拖动+可拉伸
void setPadding(int padding);
void setMoveEnable(bool moveEnable);
void setResizeEnable(bool resizeEnable);
2021-05-15 11:10:30 +00:00
};
#endif // FRAMELESSWIDGET2_H