Details
-
Suggestion
-
Resolution: Fixed
-
P3: Somewhat important
-
4.4.0
-
None
-
2002158a13517411ba797788331e8865cca514e5
Description
Imagine If one wants to implement multiple sorting in QHeaderView class and show sorting order sign on multiple segments at the same time.
The current implementation of paintSection uses internal members so intensively that it makes it impossible to reimplement this method.
Here's a suggestion to change the interface of the class to make it more customizable:
1) Add virtual method preparePaintSection to QHeaderView. Default implementation does nothing. Subclass implementation can change QStyleOptionHeader and QPainter options to make last tuning before drawing.
File qheaderview.h:
class Q_GUI_EXPORT QHeaderView : public QAbstractItemView
{
...
protected:
virtual void preparePaintSection(
QStyleOptionHeader * /option/,
QPainter * /painter/) const
...
}
2) Call preparePaintSection method from inside paintSection method just before drawControl method.
File qheaderview.cpp:
void QHeaderView::paintSection(QPainter *painter, const QRect &rect, int
logicalIndex) const
{
...
preparePaintSection(&opt, painter);
// draw the section
style()->drawControl(QStyle::CE_Header, &opt, painter, this);
painter->setBrushOrigin(oldBO);
}