1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- #ifndef GGBASEHEADER_H
- #define GGBASEHEADER_H
- #include <QWidget>
- #include <QHeaderView>
- class BaseHeader : public QHeaderView
- {
- Q_OBJECT
- public:
- enum SortState
- {
- Disable = -1,
- NotSort = 0,
- Asc = 1,
- Desc = 2
- };
- public:
- explicit BaseHeader(QWidget *parent = nullptr, Qt::Orientation orientation = Qt::Horizontal, Qt::Alignment flags = Qt::AlignLeft|Qt::AlignVCenter);
- void SetTextAlignment(Qt::Alignment flags);
- void SetSortable(bool value, const QList<int> ¬SortList = QList<int>());
- void SetCheckable(bool value);
- void SetChecked(Qt::CheckState state);
- QString GetText(int logicalIndex);//获取表头名称 add by wl 2023-06-26
- protected:
- void paintSection(QPainter *painter, const QRect &rect, int logicalIndex) const override;
- signals:
- void sig_Sorted(int logicalIndex, SortState state);
- void sig_Checked(bool checked);
- private slots:
- void OnSectionClicked(int logicalIndex);
- private:
- Qt::Alignment m_alignmentText;
- int m_nCurSortedIndex;
- bool m_bSortable;
- SortState m_stateCurSorted;
- QList<int> m_listSortDisable;
- bool m_bCheckable;
- Qt::CheckState m_checkState;
- //QList<SortState> m_listStates;
- private:
- QString GetCheckboxImage(Qt::CheckState state) const;
- };
- #endif // GGBASEHEADER_H
|