JS8Call-Improved master
Loading...
Searching...
No Matches
SemiSortableHeader Class Reference

QHeaderView derivative that allows selective disabling of sorting. More...

#include <SemiSortableHeader.h>

Inheritance diagram for SemiSortableHeader:
Collaboration diagram for SemiSortableHeader:

Public Member Functions

 SemiSortableHeader (Qt::Orientation ori, QWidget *parent=nullptr)
 Construct the header with the given orientation.
void attachTo (QTableWidget *table)
 Attach this header to a QTableWidget and initialize sorting state.
void setNonSortableColumns (const QSet< int > &cols)
 Set the set of non-sortable columns.
void addNonSortableColumn (int col)
 Mark a specific column as non-sortable.
void removeNonSortableColumn (int col)
 Remove non-sortable marking from a column.
bool isSortableColumn (int col) const
 Check whether a column is sortable.

Protected Member Functions

void paintSection (QPainter *painter, const QRect &rect, int logicalIndex) const override
 Custom painting to avoid drawing sort indicators for non-sortable columns.
void mousePressEvent (QMouseEvent *e) override
 Intercept mouse presses to ignore clicks on non-sortable columns.

Detailed Description

QHeaderView derivative that allows selective disabling of sorting.

The header can be attached to a QTableWidget and configured with a set of non-sortable columns. Clicks on non-sortable columns are ignored and the header is painted without a sort indicator for those columns.

Constructor & Destructor Documentation

◆ SemiSortableHeader()

SemiSortableHeader::SemiSortableHeader ( Qt::Orientation ori,
QWidget * parent = nullptr )
inlineexplicit

Construct the header with the given orientation.

Parameters
oriHeader orientation (Horizontal/Vertical).
parentOptional parent widget.

Member Function Documentation

◆ attachTo()

void SemiSortableHeader::attachTo ( QTableWidget * table)
inline

Attach this header to a QTableWidget and initialize sorting state.

Parameters
tableTarget table to attach to.

◆ isSortableColumn()

bool SemiSortableHeader::isSortableColumn ( int col) const
inline

Check whether a column is sortable.

Returns
true if the column is sortable.
Here is the caller graph for this function:

◆ setNonSortableColumns()

void SemiSortableHeader::setNonSortableColumns ( const QSet< int > & cols)
inline

Set the set of non-sortable columns.

Parameters
colsSet of column indexes that should not be sortable.

The documentation for this class was generated from the following file: