qt_demoe/framelesswidget/framelesswidget.h

75 lines
2.3 KiB
C
Raw Normal View History

2019-10-10 05:42:12 +00:00
#ifndef FRAMELESSWIDGET_H
#define FRAMELESSWIDGET_H
/**
* :feiyangqingyun(QQ:517216493) 2019-10-03
* 1:widget
* 2:
* 3:,便
2019-10-11 07:15:12 +00:00
* 4:
* 5:
2019-10-10 05:42:12 +00:00
*/
#include <QWidget>
#ifdef quc
#if (QT_VERSION < QT_VERSION_CHECK(5,7,0))
#include <QtDesigner/QDesignerExportWidget>
#else
#include <QtUiPlugin/QDesignerExportWidget>
#endif
class QDESIGNER_WIDGET_EXPORT FramelessWidget : public QObject
#else
class FramelessWidget : public QObject
#endif
{
Q_OBJECT
public:
explicit FramelessWidget(QObject *parent = 0);
protected:
bool eventFilter(QObject *watched, QEvent *event);
private:
int padding; //边距
2019-10-11 07:15:12 +00:00
bool moveEnable; //可移动
bool resizeEnable; //可拉伸
2019-10-10 05:42:12 +00:00
QWidget *widget; //无边框窗体
bool pressed; //鼠标按下
bool pressedLeft; //鼠标按下左侧
bool pressedRight; //鼠标按下右侧
bool pressedTop; //鼠标按下上侧
bool pressedBottom; //鼠标按下下侧
bool pressedLeftTop; //鼠标按下左上侧
bool pressedRightTop; //鼠标按下右上侧
bool pressedLeftBottom; //鼠标按下左下侧
bool pressedRightBottom; //鼠标按下右下侧
int rectX, rectY, rectW, rectH; //窗体坐标+宽高
QPoint lastPos; //鼠标按下处坐标
QRectF rectLeft; //左侧区域
QRectF rectRight; //右侧区域
QRectF rectTop; //上侧区域
QRectF rectBottom; //下侧区域
QRectF rectLeftTop; //左上侧区域
QRectF rectRightTop; //右上侧区域
QRectF rectLeftBottom; //左下侧区域
QRectF rectRightBottom; //右下侧区域
public Q_SLOTS:
//设置边距
void setPadding(int padding);
2019-10-11 07:15:12 +00:00
//设置是否可拖动+拉伸
void setMoveEnable(bool moveEnable);
void setResizeEnable(bool resizeEnable);
2019-10-10 05:42:12 +00:00
//设置要无边框的窗体
void setWidget(QWidget *widget);
};
#endif // FRAMELESSWIDGET_H