67 lines
1.8 KiB
C
67 lines
1.8 KiB
C
|
|
#ifndef BASEWGT_H
|
||
|
|
#define BASEWGT_H
|
||
|
|
|
||
|
|
#include <QWidget>
|
||
|
|
#include <QLabel>
|
||
|
|
#include <QPushButton>
|
||
|
|
#include <QEvent>
|
||
|
|
#include <QVBoxLayout>
|
||
|
|
#include <QHBoxLayout>
|
||
|
|
#include <QStyle>
|
||
|
|
#include <QTextCodec>
|
||
|
|
|
||
|
|
#define TOP_HEIGHT 25
|
||
|
|
#define WGT_STYLE_PATH ":/qss/mainui.css"
|
||
|
|
|
||
|
|
class BaseWgt : public QWidget
|
||
|
|
{
|
||
|
|
Q_OBJECT
|
||
|
|
public:
|
||
|
|
BaseWgt(QWidget *parent = 0);
|
||
|
|
~BaseWgt();
|
||
|
|
void setResizable(bool bResizable); //设置是否可以伸缩
|
||
|
|
void setMargin(const int &iMargin); //设置鼠标样式在界面边缘改变的范围
|
||
|
|
void setSysIcon(const QString &url);
|
||
|
|
void setWindowTitle(const QString &); //设置窗口标题
|
||
|
|
void hideTopWgt(); //隐藏标题
|
||
|
|
void setTopWgtHiddent(bool bHide);
|
||
|
|
void setCloseBtnVisible(bool bVisible);
|
||
|
|
|
||
|
|
protected:
|
||
|
|
virtual bool eventFilter(QObject *, QEvent *);
|
||
|
|
|
||
|
|
private:
|
||
|
|
void changeMouseStyle(const QPoint &); //改变鼠标样式
|
||
|
|
void initUiControl(); //初始化界面控件
|
||
|
|
void initSignalSlotConn(); //初始化信号槽连接
|
||
|
|
|
||
|
|
private slots:
|
||
|
|
void minimumBtnClickedSlot(); //最小化按钮单击槽函数
|
||
|
|
void maximumBtnClickedSlot(); //最大化按钮单击槽函数
|
||
|
|
|
||
|
|
protected:
|
||
|
|
QWidget *m_pTopWgt; //顶部
|
||
|
|
QWidget *m_pBottomWgt; //底部窗口
|
||
|
|
QWidget *m_pMainWgt; //主体
|
||
|
|
QLabel *m_pIconLabel; //系统图标
|
||
|
|
QPushButton *m_pMinBtn; //最小化
|
||
|
|
QPushButton *m_pMaxBtn; //最大化
|
||
|
|
QPushButton *m_pCloseBtn; //关闭
|
||
|
|
QRect m_screenRect; //最大化窗口
|
||
|
|
|
||
|
|
private:
|
||
|
|
bool m_bResizable; //是否可拉伸
|
||
|
|
int m_iMarginWidth; //边缘距离
|
||
|
|
bool m_bPressed; //标记鼠标是否按下
|
||
|
|
QPoint m_ptPressPos; //鼠标按下的位置
|
||
|
|
bool m_bIsMaxState; //是否是最大化
|
||
|
|
|
||
|
|
|
||
|
|
QLabel *m_pTitleLbl; //标题
|
||
|
|
|
||
|
|
QRect m_normalRect; //正常窗口
|
||
|
|
|
||
|
|
};
|
||
|
|
|
||
|
|
#endif // BASEWGT_H
|