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

QStyleOptionProgressBar is not properly rendered by a delegate

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • Not Evaluated
    • None
    • 6.7.1
    • Widgets: Styles
    • None
    • Fedora 39
      QT 6.7.1 installed via the QT Maintenance tool.

      QT 5 system version
    • All
    • 369b5a319 (dev), 3a32bab2a (6.8), 569b4bbc8 (6.7)

    Description

      I use QStyleOptionProgressBar in my Application to have a percent indicator in a Tree view. The code stopped working with QT 6.* . In QT 5.* the same code still works. Is this a bug or has something changed in the way delegate painting is handled?

      The code is:
      ```
      void InstrumentDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
                                     const QModelIndex &index) const
      {{{}}
        painter->save();  // Setup basic layout
        QStyleOptionProgressBar progressBarOption = {};
        progressBarOption.state = QStyle::State_Enabled;
        progressBarOption.bottomToTop = false;
        progressBarOption.direction = QApplication::layoutDirection();
        progressBarOption.rect = option.rect.adjusted(0, 0, 0, 0);
        progressBarOption.minimum = 0;
        progressBarOption.maximum = 100;
        progressBarOption.textAlignment = Qt::AlignCenter;
        progressBarOption.textVisible = true;  // Set the progress and text values of the style option.
        double percent = 50.0;
        progressBarOption.progress = (int)(percent);
        progressBarOption.text = QString::asprintf("%.2f%%", percent);  //painter->fillRect(progressBarOption.rect, QColor::fromRgb(255,0,0));
        QApplication::style()>drawControl(QStyle::CE_ProgressBar, &progressBarOption, painter);  painter>restore();
      }
      ```
      The result with QT6 (Style fusion):

      The result with QT6 (Style windows): (Text missing, bar not at 50%)

      The result with QT5:

      I created a small reproducer:

      qt_progress_bug.zip

      My environment:
      Fedora 39
      QT 6.7.1 installed via the QT Maintenance tool.

      QT 5 system version

      Attachments

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

        Activity

          People

            chehrlic Christian Ehrlicher
            max-s Max Sagebaum
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes