【问题标题】:QTabBar strange line doesn't disappearQTabBar 奇怪的行没有消失
【发布时间】:2015-04-17 12:46:44
【问题描述】:

我已经创建了这个界面:

我的问题是:如何使用我的样式表摆脱那条过时的行。

黑框 (objectname= mainTabBarWidget(QWidget)) 是垂直布局的。它有一个固定高度(38px),从左到右包含这些元素:QToolButton、QTabBar、QToolButton 和另一个 QToolButton。

它的样式表如下:

QWidget#mainTabBarWidget {
    border-bottom: 1px solid black;
    background-color: rgb(107, 102, 102);
}

“+”QToolButton 在单击时创建一个新选项卡。 QTabBar(称为 tabBar)有这个样式表:

QTabBar#tabBar{
    left: 10px; /* move to the right by 5px */
    border-bottom: none;
}

QTabBar::tab {
    background-color: rgb(194, 180, 180);
    border-top: 2px solid rgb(107, 102, 102);
    border-left: 2px solid rgb(107, 102, 102);
    border-right: 2px solid rgb(107, 102, 102);
    border-bottom: none;
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
    border-bottom-left-radius: -8px;
    border-bottom-right-radius: -8px;
    min-width: 100px;
    max-width: 100px;
    height: 35px;
    padding: 2px;
}

QTabBar::tab:hover {
    background-color: rgb(216, 209, 209);
}

QTabBar::tab:selected {
    background-color: rgb(243, 231, 231);
    border-color: rgb(0, 0, 0);
 }

QTabBar::scroller { /* the width of the scroll buttons */
     border: none;
    width: 20px;
    background-color: rgba(0,0,0,55);
}

QTabBar::tear {
    border: none;
    background-color: rgba(222,221,15, 45);
   width: 0px;
}

QTabBar::tab:disabled {
    border: none;
}

P.S.1。添加 3 或 4 个选项卡时,该行也会消失。

附注 2。我尝试将选项卡宽度设置为 120px 并且该行消失了,但是当我添加其他选项卡并且显示滚动按钮时,该行重新出现。

【问题讨论】:

  • 我有一些应用程序来测试样式表,但我无法重现这个问题(我已经复制粘贴了你的样式表)。
  • 这里是文件:sendspace.com/file/du47s1
  • @MarekR:我找出了那条奇怪线的原因,但我不知道如何删除它。事实上,在我的构造函数中,我设置了 ui->tabBar->setUsesScrollBars(false);所有的空间都消失了(这条线也消失了)。但现在我的 QTabBar 不支持 Scrollers :/

标签: qt qtstylesheets qtabbar


【解决方案1】:

我也遇到过类似的问题,但在下面解决了。

http://doc.qt.io/qt-5/qtabbar.html#drawBase-prop

QTabBar::setDrawBase(false);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-07-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多