我创建了这个界面:
我的问题是:如何使用我的样式表摆脱那条过时的行。
黑框 (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;
}
PS1。添加 3 或 4 个选项卡时,该行也会消失。
PS2。我尝试将选项卡宽度设置为 120px 并且该行消失了,但是当我添加其他选项卡并显示滚动按钮时,该行重新出现。