QTabWidget和QTabBar控件样式设置(qss)

QTabWidget和QTabBar控件样式设置

1、QTabWidget样式可自定义的有哪些

复制代码
	QTabWidget::pane{} 定义tabWidgetFrame
	QTabWidget::tab-bar{} 定义TabBar的位置
	QTabWidget::tab{}定义Tab的样式
	QTabWidget::tab:selected{}定义Tab被选中时的样式
	QTabWidget::tab:hover{}定义Tab鼠标悬停时的样式
	QTabWidget::tab:!selected{}定义Tab在非选中时的样式

示例:

cpp 复制代码
QTabWidget::pane {
        border: 1px solid blue;
        border-radius:5px;

}

QTabWidget::tab-bar {
        alignment: left;
}

QTabBar::tab {
        background: #00aaff;
        border: none;
        border-top-left-radius: 4px;
        border-top-right-radius: 4px;
        min-width: 80px;
        padding: 8px;
        color:#000000;
}

QTabBar::tab:selected, QTabBar::tab:hover {
        background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
                                stop: 0 #ffffff, stop: 1.0 #00aaff);

}

QTabBar::tab:selected {
        border: 1px solid #00aaff;
}

效果图

2、QTabBar样式可自定义的有哪些

复制代码
    QTabBar::tear{}

    QTabBar::scroller{}

    QTabBar QToolButton{} 定义QTabBar下的QToolButton的样式

    QTabBar QToolButton::right-arrow{} /* the arrow mark in the tool buttons */

    QTabBar QToolButton::left-arrow{}

    QTabBar::close-button{}

    QTabBar::close-button:hover{}

示例

cpp 复制代码
QTabWidget::pane {
        background:white;
        border:none;

}

QTabWidget::tab-bar {
        alignment: left;
}

QTabBar::tab {
        background: rgb(246, 246, 246);
        border: none;
        border-top-left-radius: 4px;
        border-top-right-radius: 4px;
        min-width: 80px;
        padding: 8px;
        color:#000000;
}

QTabBar::tab:selected {
        border-bottom: 2px solid #0055ff;
}

效果图

包括QTabWidget标签页的位置:左中右,是否下沉都可以通过样式表设置,标签页的间距、样式、等等都可以,大家赶快自己试一试。

相关推荐
Quz17 小时前
QML ComboBox 可编辑输入与动态更新模型
qt
丰锋ff17 小时前
7.2Qt中Json的操作
开发语言·qt·json
我不是疯子是傻子17 小时前
用DeepSeek生成Qt多协议解析器?「正则+状态机+AI分支裁剪」混合调优实战
开发语言·qt
qq_4017004118 小时前
QT段错误一般是什么原因造成的,如何快速排查
qt
平常心的技术小牛19 小时前
Qt-快速上手-QLabel
开发语言·qt
不会代码的小猴19 小时前
2. 了解Qt
开发语言·c++·笔记·qt·算法
丰锋ff1 天前
3.1 Qt事件之事件处理器
开发语言·qt
反转180度1 天前
Qt 6 + C++17 实现 SFTP 批量部署:工业设备运维工具实战解析
运维·c++·qt
我不是疯子是傻子1 天前
Qt CAN通信周期发送抖动?实测定时器精度校准与时间戳补偿方案
开发语言·数据库·qt
2023自学中1 天前
Qt 简易聊天室(第二篇),单线程 改为 多线程,方便后续增加文件传输功能
c++·qt