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

QGraphicsEffect::drawSource give wrong output when used with other effects

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 6.5.3
    • None
    • Windows

    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);
      } 

       

      Attachments

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

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            justynah Justyna Hudziak
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes