Qt6 topics merged with General

How to avoid style change when I morph groupBox into QTabWidget?

  • Greetings!
    So, I had a groupBox and once I need to have more controls than groupBox could contain. Then I used "Morph into..." function to morph groupBox into QTabWidget.

    BUT: there are irritate things: all my controls (especially ToolButtons) stylesheet changed!!!
    When I open "Change styleSheet ..." for a morphed groupBox (now QTabWidget), it is empty! That means one thing only, Qt treats this changes as normal or does not track style sheet change!

    Please, help! How to fix such things, except applying newly created stylesheet for each element in new QTabWidget.

  • Lifetime Qt Champion

    StyleSheets are cascading. Meaning it will affect child also. So why not just use
    1 stylesheet with all settings in and apply it to MainWindow.

    That way "Morph into..." do not remove anything AND
    its wont become such a mess over time to keep track of all the stylesheets.

  • Thank you for reply, but it doesn't help due to MainWindow doesn't have any style applied with styleSheet at all.

  • Lifetime Qt Champion

    Just so we are clear. :)
    You can have a stylesheet on MainWindow that affects all its children but not itself.
    So one place/sheet that will change all widgets inside main window.

    Then you are free to morph widgets since the stylesheet is controlled top widget.

Log in to reply