Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QStyleOptionProgressBar no longer rendering in QT 6.*

QStyleOptionProgressBar no longer rendering in QT 6.*

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 3 Posters 575 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Max S.
    wrote on last edited by
    #1

    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:
    Screenshot from 2024-06-17 13-04-27.png

    The result with QT5:
    Screenshot from 2024-06-17 13-04-48.png

    I created a small reproducer:
    https://seafile.rlp.net/f/b1589ae16f7245d9b50d/?dl=1

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

    Pl45m4P 1 Reply Last reply
    0
    • M Max S.

      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:
      Screenshot from 2024-06-17 13-04-27.png

      The result with QT5:
      Screenshot from 2024-06-17 13-04-48.png

      I created a small reproducer:
      https://seafile.rlp.net/f/b1589ae16f7245d9b50d/?dl=1

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

      Pl45m4P Offline
      Pl45m4P Offline
      Pl45m4
      wrote on last edited by
      #2

      @Max-S said in QStyleOptionProgressBar no longer rendering in QT 6.*:

      My environment:
      Fedora 39

      Wayland?
      Could be a wayland issue then.
      When using the Forum Search you will see that there are a lot window/rendering issues with Qt6 and wayland.


      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

      M 1 Reply Last reply
      0
      • Pl45m4P Pl45m4

        @Max-S said in QStyleOptionProgressBar no longer rendering in QT 6.*:

        My environment:
        Fedora 39

        Wayland?
        Could be a wayland issue then.
        When using the Forum Search you will see that there are a lot window/rendering issues with Qt6 and wayland.

        M Offline
        M Offline
        Max S.
        wrote on last edited by
        #3

        @Pl45m4 I logged out and in again with xorg enabled.

        But the rendering behaviour stays the same. So it seems to be an QT 6.* issue.

        I validated that I use x11 via the terminal.

        [max]~> loginctl 
        SESSION  UID USER      SEAT  TTY  STATE  IDLE SINCE
             10 1001 max seat0 tty2 active no        
        
        1 sessions listed.
        [max]~> loginctl show-session 10 -p Type
        Type=x11
        
        1 Reply Last reply
        0
        • Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Please start with '-style fusion' and '-style windows' to see if it is a fusion or windows style problem. If so please provide a minimal compilable example in the bug.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          M 1 Reply Last reply
          0
          • Christian EhrlicherC Christian Ehrlicher

            Please start with '-style fusion' and '-style windows' to see if it is a fusion or windows style problem. If so please provide a minimal compilable example in the bug.

            M Offline
            M Offline
            Max S.
            wrote on last edited by
            #5

            @Christian-Ehrlicher It seems a general rendering but. With the -style windows option the text is missing and the progress bar should be at 50%:
            Screenshot from 2024-06-17 18-24-56.png

            So it seems to be a general problem. I created the bug report https://bugreports.qt.io/browse/QTBUG-126426.

            1 Reply Last reply
            0
            • Christian EhrlicherC Offline
              Christian EhrlicherC Offline
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on last edited by
              #6

              You forgot to properly set the orientation in QStyleOptionProgressBar.state to QStyle::State_Horizontal.

              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
              Visit the Qt Academy at https://academy.qt.io/catalog

              1 Reply Last reply
              1

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved