qt_demoe/widget/framelesswidget/framelesswidget2.h

67 lines
1.6 KiB
C
Raw Normal View History

2021-05-15 11:10:30 +00:00
#ifndef FRAMELESSWIDGET2_H
#define FRAMELESSWIDGET2_H
2021-09-16 06:48:38 +00:00
/**
* :feiyangqingyun(QQ:517216493) 2019-10-03
* 1. widget
* 2.
* 3. 便
* 4.
* 5.
*/
2021-05-15 11:10:30 +00:00
#include <QWidget>
#ifdef quc
2021-09-16 06:48:38 +00:00
class Q_DECL_EXPORT FramelessWidget2 : public QObject
2021-05-15 11:10:30 +00:00
#else
2021-09-16 06:48:38 +00:00
class FramelessWidget2 : public QObject
2021-05-15 11:10:30 +00:00
#endif
{
Q_OBJECT
public:
2021-09-16 06:48:38 +00:00
explicit FramelessWidget2(QObject *parent = 0);
2021-05-15 11:10:30 +00:00
protected:
bool eventFilter(QObject *watched, QEvent *event);
2021-07-05 09:56:20 +00:00
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;
2021-09-16 06:48:38 +00:00
//无边框窗体
QWidget *widget;
//鼠标是否按下+按下坐标+按下时窗体区域
bool mousePressed;
QPoint mousePoint;
QRect mouseRect;
//鼠标是否按下某个区域+按下区域的大小
//依次为 左侧+右侧+上侧+下侧+左上侧+右上侧+左下侧+右下侧
QList<bool> pressedArea;
QList<QRect> pressedRect;
//记录是否最小化
bool isMin;
//存储窗体默认的属性
Qt::WindowFlags flags;
public Q_SLOTS:
//设置边距
2021-07-05 09:56:20 +00:00
void setPadding(int padding);
2021-09-16 06:48:38 +00:00
//设置是否可拖动+拉伸
2021-07-05 09:56:20 +00:00
void setMoveEnable(bool moveEnable);
void setResizeEnable(bool resizeEnable);
2021-10-10 01:54:15 +00:00
//修复部分控件不能自动识别 MouseButtonRelease 的BUG
void setMousePressed(bool mousePressed);
2021-09-16 06:48:38 +00:00
//设置要无边框的窗体
void setWidget(QWidget *widget);
2021-05-15 11:10:30 +00:00
};
#endif // FRAMELESSWIDGET2_H