Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-2474

Suggestion: QHeaderView::paintSection

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Fixed
    • P3: Somewhat important
    • 6.0
    • 4.4.0
    • Widgets: Itemviews
    • 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);
      }

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            tmartsum Thorbjørn Lund Martsum
            admin Administrator
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes