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

Widgets become invisible

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P1: Critical
    • 5.9
    • 5.9.4, 5.10.1
    • None
    • Windows, macOS, Linux, Android.

    Description

      After upgrading to Qt 5.9.4, many elements in my application started to become invisible when hovering the mouse over them, or tabbing the focus.

      I was able to track down the offending code. It seems QPropertyAnimation with a QGraphicsOpacityEffect causes this.

      The problem arises only when building against 5.9.4 or 5.10.1. When building against 5.9.3 or 5.10.0, there's no issue.

      All platforms I tested on are affected (Windows, macOS, Linux, Android.)

      Code that reproduces the issue:

      #include <QApplication>
      #include <QGraphicsOpacityEffect>
      #include <QMainWindow>
      #include <QPropertyAnimation>
      #include <QPushButton>
      #include <QShowEvent>
      
      class TestWidget: public QWidget
      {
      public:
          explicit TestWidget(QWidget* parent = 0)
              : QWidget(parent)
          {
              fFadeIn.setStartValue(0);
              fFadeIn.setEndValue(1);
              button->move(100, 100);
              //button->move(10, 10);
              setGraphicsEffect(&fOpEffect);
          }
      
      protected:
          void showEvent(QShowEvent* e) override
          {
              QWidget::showEvent(e);
              if (e->spontaneous()) {
                  return;
              }
              fFadeIn.start();
          }
      
      private:
          QPushButton* button = new QPushButton("Test", this);
          QGraphicsOpacityEffect fOpEffect;
          QPropertyAnimation fFadeIn{&fOpEffect, "opacity", &fOpEffect};
      };
      
      int main(int argc, char *argv[])
      {
          QApplication a(argc, argv);
          QMainWindow w;
          w.resize(800, 600);
          auto tstWidget = new TestWidget(&w);
          tstWidget->move(0, 0);
          tstWidget->resize(800, 600);
          w.setCentralWidget(tstWidget);
          w.show();
          return a.exec();
      }
      

      Hover the mouse over the button. It will become invisible.

      The commented-out line (move(10, 10)) might give some more insight as to what's happening, since if moving the button near the top-left edge of the window, it starts to become visible again.

       

      Attachments

        Issue Links

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

          Activity

            People

              richard Richard Moe Gustavsen
              realnc Nikos Chantziaras
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes