Nominate our 2022 Qt Champions!

Custom two different QTabWidgets with stylesheet

  • Hi, I'm trying to custom two differents QTabWidget but, I don't remember how to identificate the different elements of each, for example, the QTabBar element.

    I have something like this:

    QTabBar::tab {
    	height: 37px;
    	width: 40px;
    	color: rgb(255, 255, 255);
    	background-color: rgb(57, 66, 99);
            min-width: 8ex;
            padding: 3px;	
    	border-top: 1px solid gray;
    	border-bottom: 1px solid gray;

    but, when I try to custom the second QTabWidget, it takes the stylesheet from the first. I think it works with the '#' character but I don't remember how.

    How could I do this?

    My QTabWidget names are mainTabWidget and tabWidget02.

    Thank you very much!!

  • Qt Champions 2017

    use objectName like #objectName { style sheet }

  • Yes. This solution works but, in the interface I haven't got a QTabBar widget. I have two QTabWidgets and I want to know how can I differentiate their associate QTabBar.

    Thank you!

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Use the tab-bar sub-control for that.

Log in to reply