Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Problem changing StyleSheet at runtime with Qt 12.4 an 13.0

Problem changing StyleSheet at runtime with Qt 12.4 an 13.0

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 764 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    stvokr
    wrote on last edited by stvokr
    #1

    Hi all,

    I have a problem with StyleSheets. I was using Qt 12.3 on Windows 10 and Mint Linux (both 64 bit) with two customized stylesheet (dark and light). The StyleSheets are ok, both has been working since Qt 4.8.

    I can change this stylesheet in my application at runtime. And everything was fine.
    Now with 12.4 and 13 this does not work any more. When I start my app with the dark theme or with the light theme the appearance is ok. But when I change the stylesheet, just the MainWindow is beeing updated but not the other widgets in the MainWindow.
    I just called

    setStyleSheet( myStyleSheet ); 
    

    I made it work again with a workaround by calling updateStyleSheet for each widget in the mainwindow, 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() )
            {
                QWidget* w = qobject_cast< QWidget* >( o );
                if( w )
                {
                    updateStyleSheet( w );
                }
            }
        }
    }
    

    Any ideas? Or is the a bug?

    regards
    Oliver

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      Check Qt bug tracker (https://bugreports.qt.io) from what you write it looks like a bug (even more, a regression).

      (Z(:^

      1 Reply Last reply
      0
      • S Offline
        S Offline
        stvokr
        wrote on last edited by
        #3

        I reported to the Bug tracker.
        https://bugreports.qt.io/browse/QTBUG-77006

        1 Reply Last reply
        1

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved