qt_demoe/widget/framelesswidget/framelesscore/framelessmainwindow.h

97 lines
2.8 KiB
C
Raw Normal View History

2021-07-27 07:35:23 +00:00
#ifndef FRAMELESSMAINWINDOW_H
#define FRAMELESSMAINWINDOW_H
2021-11-14 05:06:47 +00:00
/**
* :feiyangqingyun(QQ:517216493) 2021-07-27
* 1. Qt4-Qt6Qt4.7Qt6.2
* 2. mingwmsvcgcc
* 3. windowslinuxmac
* 4. QMainWindowQWidgetQDialog
* 5. 使
* 6.
* 7. windows
* 8. windows
* 9. macBUG
* 10. BUG
* 11. BUG
* 12. 1300
* 13.
* 14. Qt
*/
2021-07-27 07:35:23 +00:00
#include <QMainWindow>
2021-09-19 03:44:22 +00:00
#ifdef quc
class Q_DECL_EXPORT FramelessMainWindow : public QMainWindow
#else
2021-07-27 07:35:23 +00:00
class FramelessMainWindow : public QMainWindow
2021-09-19 03:44:22 +00:00
#endif
2021-07-27 07:35:23 +00:00
{
Q_OBJECT
public:
explicit FramelessMainWindow(QWidget *parent = 0);
protected:
//窗体显示的时候触发
void showEvent(QShowEvent *event);
//事件过滤器识别拖动拉伸等
void doWindowStateChange(QEvent *event);
void doResizeEvent(QEvent *event);
bool eventFilter(QObject *watched, QEvent *event);
//拦截系统事件用于修复系统休眠后唤醒程序的BUG
#if (QT_VERSION >= QT_VERSION_CHECK(6,0,0))
bool nativeEvent(const QByteArray &eventType, void *message, qintptr *result);
#else
bool nativeEvent(const QByteArray &eventType, void *message, long *result);
#endif
//Qt4的写法
#if (QT_VERSION < QT_VERSION_CHECK(5,0,0))
#ifdef Q_OS_WIN
bool winEvent(MSG *message, long *result);
#endif
#endif
private:
//边距+可移动+可拉伸
int padding;
bool moveEnable;
bool resizeEnable;
//标题栏控件
QWidget *titleBar;
//鼠标是否按下+按下坐标+按下时窗体区域
bool mousePressed;
QPoint mousePoint;
QRect mouseRect;
//鼠标是否按下某个区域+按下区域的大小
//依次为 左侧+右侧+上侧+下侧+左上侧+右上侧+左下侧+右下侧
QList<bool> pressedArea;
QList<QRect> pressedRect;
//记录是否最小化
bool isMin;
//存储窗体默认的属性
Qt::WindowFlags flags;
2021-09-26 01:50:09 +00:00
public Q_SLOTS:
2021-07-27 07:35:23 +00:00
//设置边距+可拖动+可拉伸
void setPadding(int padding);
void setMoveEnable(bool moveEnable);
void setResizeEnable(bool resizeEnable);
//设置标题栏控件
void setTitleBar(QWidget *titleBar);
2021-09-26 01:50:09 +00:00
Q_SIGNALS:
2021-07-27 07:35:23 +00:00
void titleDblClick();
void windowStateChange(bool max);
};
#endif // FRAMELESSMAINWINDOW_H