qt_demoe/ui/iconhelper/panelwidget.h

89 lines
2.7 KiB
C
Raw Normal View History

2021-12-08 01:34:27 +00:00
#ifndef PANELWIDGET_H
#define PANELWIDGET_H
/**
* :feiyangqingyun(QQ:517216493) 2016-11-20
* 1. widget
* 2.
* 3.
* 4.
* 5.
*/
#include <QWidget>
class QScrollArea;
class QFrame;
class QVBoxLayout;
class QGridLayout;
#ifdef quc
class Q_DECL_EXPORT PanelWidget : public QWidget
#else
class PanelWidget : public QWidget
#endif
{
Q_OBJECT
Q_PROPERTY(int margin READ getMargin WRITE setMargin)
Q_PROPERTY(int space READ getSpace WRITE setSpace)
Q_PROPERTY(bool autoWidth READ getAutoWidth WRITE setAutoWidth)
Q_PROPERTY(bool autoHeight READ getAutoHeight WRITE setAutoHeight)
Q_PROPERTY(int columnCount READ getColumnCount WRITE setColumnCount)
public:
explicit PanelWidget(QWidget *parent = 0);
protected:
void resizeEvent(QResizeEvent *);
private:
QScrollArea *scrollArea; //滚动区域
QWidget *scrollAreaContents; //滚动区域载体
QFrame *frame; //放置设备的框架,自动变宽变高
QVBoxLayout *verticalLayout; //设备面板总布局
QGridLayout *gridLayout; //设备表格布局
int margin; //边距
int space; //设备之间的间隔
bool autoWidth; //宽度自动拉伸
bool autoHeight; //高度自动拉伸
int columnCount; //面板列数
QList<QWidget *> widgets; //设备面板对象集合
public:
int getMargin() const;
int getSpace() const;
bool getAutoWidth() const;
bool getAutoHeight() const;
int getColumnCount() const;
QList<QWidget *> getWidgets() const;
QSize sizeHint() const;
QSize minimumSizeHint() const;
public Q_SLOTS:
//设置边距+间距
void setMargin(int left, int top, int right, int bottom);
void setMargin(int margin);
void setSpace(int space);
//设置自动填充宽度+自动填充高度
void setAutoWidth(bool autoWidth);
void setAutoHeight(bool autoHeight);
//设置列数+窗体集合
void setColumnCount(int columnCount);
void setWidgets(QList<QWidget *> widgets);
//载入窗体集合+指定位置插入新窗体+移除指定的窗体+清空窗体
void loadWidgets();
void insertWidget(int index, QWidget *widget);
void removeWidget(QWidget *widget);
void clearWidgets();
};
#endif // PANELWIDGET_H