python-3.x - 使用 StyleSheet 时 QTabWidget 样式不正确
问题描述
我无法使用 Qt Designer 中的 StyleSheet 正确设置 QTabWidget 的样式。
如何设置标签按钮的样式,它们上的关闭按钮?底部有一个奇怪的白色边框?我怎样才能删除它们?这是它的样式表:
background-color: rgb(58, 68, 102);
border-radius: 4;
border-style: none;
这是一个最小的可重现示例: Python 文件:
from PyQt5.QtWidgets import QApplication, QMainWindow
from PyQt5 import uic
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
#Loading teh ui file
uic.loadUi('sir.ui', self)
QApp = QApplication([])
window = MainWindow()
window.show()
QApp.exec()
ui文件:
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>805</width>
<height>625</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(38, 43, 68);</string>
</property>
<widget class="QWidget" name="centralwidget">
<widget class="QTabWidget" name="tabWidget">
<property name="geometry">
<rect>
<x>10</x>
<y>0</y>
<width>781</width>
<height>581</height>
</rect>
</property>
<property name="focusPolicy">
<enum>Qt::TabFocus</enum>
</property>
<property name="contextMenuPolicy">
<enum>Qt::DefaultContextMenu</enum>
</property>
<property name="acceptDrops">
<bool>true</bool>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(58, 68, 102);
border-radius: 4;
border-style: none;</string>
</property>
<property name="tabPosition">
<enum>QTabWidget::North</enum>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<property name="elideMode">
<enum>Qt::ElideRight</enum>
</property>
<property name="tabsClosable">
<bool>true</bool>
</property>
<property name="movable">
<bool>true</bool>
</property>
<widget class="QWidget" name="tab_2">
<attribute name="title">
<string>Home</string>
</attribute>
</widget>
</widget>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>805</width>
<height>21</height>
</rect>
</property>
</widget>
<widget class="QStatusBar" name="statusbar"/>
</widget>
<resources/>
<connections/>
</ui>
这是当前状态:
解决方案
推荐阅读
- angular - matDialogRef 的 StaticInjectionError
- c++ - 编写多个 protobuf 消息:1 条具有 1 个重复属性的消息或编写不同的消息?
- django - 如何从安装包时创建的 django 管理员注销表
- java - 为什么 poi excel 导出在我的春季项目中不起作用?
- sql - INSERT 'X' 如果另一列被更新
- excel - 刷新数据透视表日期
- swift - 从 HTTP 请求中获取值并刷新 UIView 标签值
- systemd - Systemd 服务处于非活动状态(死亡),但仅在数周后
- java - 如何使用 systemd-run 运行子进程并等待它完成
- java - 如何解决应用服务器上 Angular Java 应用中缺少的 css 问题