qtabbar 选中 未选中 悬浮样式
时间: 2023-07-25 22:49:05 浏览: 124
QTabBar 是 Qt 框架中的一个控件,用于显示选项卡,其选中、未选中和悬浮样式可以通过 QTabBar 类的成员函数 setStyleSheet() 来设置。
下面是一个设置 QTabBar 样式的示例代码:
```
QTabBar::tab:selected {
background-color: #C7FFEC;
}
QTabBar::tab:!selected {
background-color: #F0F0F0;
}
QTabBar::tab:hover {
background-color: #FFD6C7;
}
```
其中,`QTabBar::tab:selected` 表示选中的选项卡样式,`QTabBar::tab:!selected` 表示未选中的选项卡样式,`QTabBar::tab:hover` 表示悬浮的选项卡样式。
可以根据需要修改背景颜色、字体样式等来实现自定义样式。
相关问题
QTabBar 选中 未选中 悬浮样式
QTabBar 是 Qt 框架中的一个控件,用于显示选项卡,其选中、未选中和悬浮样式可以通过 QTabBar 类的成员函数 setStyleSheet() 来设置。
下面是一个设置 QTabBar 样式的示例代码:
```
QTabBar::tab:selected {
background-color: #C7FFEC;
}
QTabBar::tab:!selected {
background-color: #F0F0F0;
}
QTabBar::tab:hover {
background-color: #FFD6C7;
}
```
其中,`QTabBar::tab:selected` 表示选中的选项卡样式,`QTabBar::tab:!selected` 表示未选中的选项卡样式,`QTabBar::tab:hover` 表示悬浮的选项卡样式。
可以根据需要修改背景颜色、字体样式等来实现自定义样式。
QT5.14.2 qtabbar 选中 未选中 悬浮样式的写法
你可以通过设置QTabBar的样式表来实现QT5.14.2 qtabbar 选中、未选中、悬浮样式的修改。下面是一个样式表的示例:
```css
QTabBar::tab:selected {
background-color: #C7C7C7;
border-color: #9B9B9B;
}
QTabBar::tab:!selected {
background-color: #EDEDED;
border-color: #9B9B9B;
}
QTabBar::tab:hover {
background-color: #EDEDED;
border-color: #9B9B9B;
}
```
上面的样式表定义了三种不同的状态下的样式,分别是:
- 选中状态:背景颜色为#C7C7C7,边框颜色为#9B9B9B;
- 未选中状态:背景颜色为#EDEDED,边框颜色为#9B9B9B;
- 悬浮状态:背景颜色为#EDEDED,边框颜色为#9B9B9B。
你可以根据自己的需要修改这些样式,然后将样式表设置给QTabBar即可。例如:
```cpp
QTabBar* tabbar = new QTabBar();
tabbar->setStyleSheet("QTabBar::tab:selected { background-color: #C7C7C7; border-color: #9B9B9B; } QTabBar::tab:!selected { background-color: #EDEDED; border-color: #9B9B9B; } QTabBar::tab:hover { background-color: #EDEDED; border-color: #9B9B9B; }");
```
注意,这里的样式表是一个长字符串,需要用双引号括起来。
阅读全文
相关推荐
![-](https://img-home.csdnimg.cn/images/20241231044955.png)
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)