Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
6.5.3
-
None
Description
The GraphicsEffect::drawSource function provides incorrect output when the widget is combined with other graphics effects.
Example:
A label with an opacity effect that is a child of a widget with a blur effect.
In this example, the label is rendered incorrectly only when the opacity effect is set to 1.0 (i.e., drawSource is used) before the blur effect is enabled.
Blur enabled with 0.7 opacity | Blur enabled with 1.0 opacity or repainted after change | Opacity changed to 1.0 after blur is enabled |
---|---|---|
![]() |
![]() |
![]() |
Minimal example:
**
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { auto centralWidget = new QWidget; auto layout = new QVBoxLayout(centralWidget); setCentralWidget(centralWidget); auto container = new QWidget; auto containerLayout = new QVBoxLayout(container); auto label = new QLabel("Text"); label->setAlignment(Qt::AlignCenter); label->setStyleSheet("color: red; font-size: 24pt; font-bold: true; background-color: black"); auto opacityEffect = new QGraphicsOpacityEffect; label->setGraphicsEffect(opacityEffect); containerLayout->addWidget(label); auto blurEffect = new QGraphicsBlurEffect; blurEffect->setEnabled(false); blurEffect->setBlurRadius(15); container->setGraphicsEffect(blurEffect); layout->addWidget(container); auto opacitySlider = new QSlider(Qt::Horizontal); opacitySlider->setMinimum(0); opacitySlider->setMaximum(100); opacitySlider->setValue(opacityEffect->opacity() * 100); connect(opacitySlider, &QSlider::valueChanged, opacityEffect, [opacityEffect](int value) { opacityEffect->setOpacity((double)value / 100); }); layout->addWidget(opacitySlider); auto button = new QPushButton("Blur disabled"); button->setCheckable(true); button->setChecked(false); connect(button, &QPushButton::toggled, [button, blurEffect](bool checked) { button->setText(checked ? "Blur enabled" : "Blur disabled"); blurEffect->setEnabled(checked); }); layout->addWidget(button); }