Search code examples
qtstylesheetqtstylesheets

Change StyleSheet of QToolBox in Qt


I am designing a GUI in Qt. I have a MainWindow and a QToolBox in it. The class of my MainWindow is QTabWidget.

According to the following pictures, I have a QToolBox with two tab named Encoder and Decoder. enter image description here

I could change the background color of each tab and its border.

But I don't know how to change the color of background of each pane/tab.

For example I want to change the color of Decoder pane to blue as follow. enter image description here

It is possible to put a frame-widget to page and change its background.

But is it possible to change the stylesheet of QToolBox directly.


Solution

  • Use this stylesheet to access certain pages in QToolBox:

    QWidget#page,
    QWidget#page_2,
    {
      background: blue
    }
    

    Where page and page_2 are object names of your pages. You can find them in QtDesigner - currentItemName.

    Or use this stylesheet to apply changes to all pages:

    QToolBox QScrollArea>QWidget>QWidget
    {
      background: blue;
    }