After using my Qt desktop application for a while and also using other applications simultaneously the stylesheet of my Qt desktop application changes.



  • I am using Qt 5.15.3 on Windows 10 and Widgets (no QML).
    At startup my application loads a light theme stylesheet file (style.qss).
    I also set the stylesheet of some QWidgets programatically.
    When I start my program everything looks like I want it.
    But after a while using my application and other programs simultaneously the stylesheets changes.

    As an example I have a QTabWidget with rounded tabs:Tab.PNG

    After a while it looks like this instead:
    TabDrifted.PNG

    As another example I have made a subclass of QPushButton: StartStopButton.
    I am modifying the stylesheet of the button dynamically.
    For instance when starting I want the button to appear green:

    setStyleSheet("StartStopButton{color: #000000; background-color: #00ff00}");
    

    Starting.png

    However when the stylesheet changes the button is instead shown as light blue when starting:
    StartingDrifted.png

    I have installed a global eventFilter on qApp and uses this to get the stylesheet of my button when starting.
    It reports:

    StartStopButton{color: #000000; background-color: #00ff00}
    

    So it seems that my button has the stylesheet I wanted but Qt somehow chooses to ignore this stylesheet!?



  • @andyP said in After using my Qt desktop application for a while and also using other applications simultaneously the stylesheet of my Qt desktop application changes.:

    But after a while using my application and other programs simultaneously the stylesheets changes.

    I don't think anyone can diagnose this.

    However when the stylesheet changes the button is instead shown as light blue when starting:

    If you replace the first stylesheet rule by the second one you will lose the first stylesheet's green foreground/background, if that is what you mean. Then the light blue presumably comes from some other applicable rule you have.


Log in to reply