在 Qt 中更改 QToolBox 的样式表 [英] Change StyleSheet of QToolBox in Qt

查看:432
本文介绍了在 Qt 中更改 QToolBox 的样式表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Qt 中设计一个GUI.我有一个 MainWindow 和一个 QToolBox .我的 MainWindow 的类是 QTabWidget.

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

根据下面的图片,我有一个 QToolBox 有两个标签,分别是 EncoderDecoder.

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

我可以更改每个tab 及其border 的背景颜色.

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

但我不知道如何更改每个pane/tab的背景颜色.

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

例如,我想将 Decoder 窗格的颜色更改为蓝色,如下所示.

For example I want to change the color of Decoder pane to blue as follow.

可以将 frame-widget 放入页面并更改其背景.

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

但是是否可以直接更改QToolBoxstylesheet.

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

推荐答案

使用此样式表访问 QToolBox 中的某些页面:

Use this stylesheet to access certain pages in QToolBox:

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

其中 pagepage_2 是页面的对象名称.您可以在 QtDesigner - currentItemName 中找到它们.

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

这篇关于在 Qt 中更改 QToolBox 的样式表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆