41 lines
825 B
C
41 lines
825 B
C
|
#ifndef CHECKBOX_HEADER_TABLE_H
|
||
|
#define CHECKBOX_HEADER_TABLE_H
|
||
|
|
||
|
#include <QMainWindow>
|
||
|
#include <QTableWidget>
|
||
|
#include <QHeaderView>
|
||
|
|
||
|
class CheckBoxHeader : public QHeaderView {
|
||
|
Q_OBJECT
|
||
|
|
||
|
public:
|
||
|
explicit CheckBoxHeader(Qt::Orientation orientation, QWidget* parent = nullptr);
|
||
|
|
||
|
signals:
|
||
|
void checkBoxClicked(bool checked);
|
||
|
|
||
|
protected:
|
||
|
void paintSection(QPainter* painter, const QRect& rect, int logicalIndex) const override;
|
||
|
|
||
|
private slots:
|
||
|
void handleSectionClicked(int logicalIndex);
|
||
|
|
||
|
private:
|
||
|
bool isChecked;
|
||
|
mutable QRect checkboxRect;
|
||
|
};
|
||
|
|
||
|
class MainWindow : public QMainWindow {
|
||
|
Q_OBJECT
|
||
|
|
||
|
public:
|
||
|
explicit MainWindow(QWidget* parent = nullptr);
|
||
|
|
||
|
private slots:
|
||
|
void onHeaderCheckBoxClicked(bool checked);
|
||
|
|
||
|
private:
|
||
|
QTableWidget* table;
|
||
|
};
|
||
|
|
||
|
#endif // CHECKBOX_HEADER_TABLE_H
|