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标签页的位置:左中右,是否下沉都可以通过样式表设置,标签页的间距、样式、等等都可以,大家赶快自己试一试。

相关推荐
864记忆1 小时前
车辆视频检测器linux版对于密码中包含敏感字符的处理方法
linux·qt
努力搬砖的咸鱼2 小时前
QTSql全解析:从连接到查询的数据库集成指南
数据库·qt
EverestVIP2 小时前
Qt 自带的QSqlDatabase 模块中使用的 SQLite 和 SQLite 官方提供的 C 语言版本(sqlite.org)对比
c语言·qt·sqlite
永不停转2 小时前
C++宏定义中可变参数列表__VA_ARGS__ 及 QT 提供的宏 QT_OVERLOADED_MACRO
c++·qt
追烽少年x3 小时前
Qt中自定义插件和库(1)
qt
我真的不会C3 小时前
Qt中的信号与槽及其自定义
开发语言·qt
蜡笔弄丢了小新6 小时前
E: The package APP needs to be reinstalled, but I can‘t find an archive for it.
qt
byxdaz6 小时前
Qt 中 findChild和findChildren绑定自定义控件
qt
liulun13 小时前
Windows注册鼠标钩子,获取用户选中的文本
c++·windows·qt
我真的不会C18 小时前
Qt中的多种输出方式,信号与槽的基本使用
开发语言·qt