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

[REG: 5.12.3->5.12.4]: Changing a stylesheet at runtime does not effect children that are not direct children of the widget being changed

    XMLWordPrintable

Details

    • All
    • 9b6179cf957c32e0c02547d510dfee2088f02340 (qt/qtbase/5.13) 4a9292f16915345b5a02a43eaa244d865d9ea49c (qt/qtbase/5.12)

    Description

      When changing the StyleSheet during runtime, the MainWindow does not apply the new stylesheet to its children. This was working since Qt 4.8.1 until Qt 5.12.3.

      I have two stylesheets (attached). When loading one of the stylesheet at startup, the appearance is ok, but changing the stylesheet does not work (see screenshots).

      I made it work again with a workaroun, but this is very slow:

      void MainWindow::changeStyleSheet( const QByteArray& styleSheet )

      { setStyleSheet( myStyleSheet ); updateStyleSheet( this ); }

      void MainWindow::updateStyleSheet( QWidget* widget )
      {
      if( widget )
      {
      widget->style()->unpolish( widget );
      widget->style()->polish( widget );
      widget->update();

      foreach( QObject* o, widget->children() )

      { updateStyleSheet( qobject_cast< QWidget* >( o ) ); }

      }
      }
      }

      Attachments

        1. stylelight.qss
          42 kB
        2. styledark.qss
          43 kB
        3. qtbug77006.zip
          2 kB
        4. light_ok.png
          light_ok.png
          25 kB
        5. dark_ok.png
          dark_ok.png
          27 kB
        6. change_from_dark_to_light.png
          change_from_dark_to_light.png
          38 kB

        Issue Links

          Activity

            People

              frederik Frederik Gladhorn
              stvokr stvokr
              Votes:
              3 Vote for this issue
              Watchers:
              11 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: