QStyleOptionProgressBar no longer rendering in QT 6.*
-
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:

The result with QT5:

I created a small reproducer:
https://seafile.rlp.net/f/b1589ae16f7245d9b50d/?dl=1My environment:
Fedora 39
QT 6.7.1 installed via the QT Maintenance tool. -
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:

The result with QT5:

I created a small reproducer:
https://seafile.rlp.net/f/b1589ae16f7245d9b50d/?dl=1My environment:
Fedora 39
QT 6.7.1 installed via the QT Maintenance tool.@Max-S said in QStyleOptionProgressBar no longer rendering in QT 6.*:
My environment:
Fedora 39Wayland?
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. -
@Max-S said in QStyleOptionProgressBar no longer rendering in QT 6.*:
My environment:
Fedora 39Wayland?
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.@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 -
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.
-
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.
@Christian-Ehrlicher It seems a general rendering but. With the
-style windowsoption the text is missing and the progress bar should be at 50%:

So it seems to be a general problem. I created the bug report https://bugreports.qt.io/browse/QTBUG-126426.
-
You forgot to properly set the orientation in QStyleOptionProgressBar.state to QStyle::State_Horizontal.