使用样式表时的QTabWidget tabPosition [英] QTabWidget tabPosition when using stylesheets

查看:774
本文介绍了使用样式表时的QTabWidget tabPosition的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用样式表为应用程序设置主题. 这是我用于QTabWidget的样式表:

I'm currently using stylesheets to theme an application. Here is the stylesheet I use for QTabWidget:

/*QTabBar et QTabWidget*/
QTabBar::tab {
    background: qlineargradient(spread:pad, x1:0.5, y1:0, x2:0.5, y2:1, stop:0 rgba(73, 73, 74, 255), stop:1 rgba(40, 40, 40, 255));
    border: 1px solid rgb(190, 190, 190);
    max-height: 0.6em;
    min-width: 0.6em;
    padding: 5px;
    margin-left: -1px;
    margin-right: -1px;
}
QTabBar::tab:selected, QTabBar::tab:hover {
    background: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(39, 117, 219, 255), stop:1 rgba(107, 171, 249, 255));
}


QTabBar::tab:last {
    border-top-right-radius: 3px;
    border-bottom-right-radius: 3px;
    margin-right: 0px;
}

QTabBar::tab:first {
    border-top-left-radius: 3px;
    border-bottom-left-radius: 3px;
    margin-left: 0px;
}

QTabBar::tab:only-one {
    border-radius: 3px;
    margin: 0px;
}

有了这个,当tabPosition设置为North或South时,没问题.但是使用East或West时,TabBar的边框的样式设置不正确.

With this, when tabPosition is set to North or South, no problem. But with East or West, the TabBar's border is not properly styled.

有人知道如何在tabPosition设置为East/west的情况下设置TabBar的样式吗?

Do someone know how to style a TabBar with tabPosition set to east/west?

推荐答案

来自

:top,:left,:right,:bottom伪状态取决于 标签的方向.

The :top, :left, :right, :bottom pseudo states depending on the orientation of the tabs.

例如,将您的第一个CSS规则应用于水平QTabBar s:

So, for example, to apply your first css rule to the horizontal QTabBars:

QTabBar::tab:top, QTabBar::tab:bottom {
    background: qlineargradient(spread:pad, x1:0.5, y1:0, x2:0.5, y2:1, stop:0 rgba(73, 73, 74, 255), stop:1 rgba(40, 40, 40, 255));
    border: 1px solid rgb(190, 190, 190);
    max-height: 0.6em;
    min-width: 0.6em;
    padding: 5px;
    margin-left: -1px;
    margin-right: -1px;
}

这篇关于使用样式表时的QTabWidget tabPosition的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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