Change StyleSheet of QToolBox in Qt

杀马特。学长 韩版系。学妹 提交于 2019-12-11 18:57:55

问题


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.

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.

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.


回答1:


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;
}



回答2:


Have you tried:

QToolBox tb;
tb.setStyleSheet("background-color: blue");

If that won't do for you, there is a good list of examples on Qt Style Sheets. Maybe you can find what you want from here.



来源:https://stackoverflow.com/questions/25567624/change-stylesheet-of-qtoolbox-in-qt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!