【发布时间】:2019-01-14 22:48:35
【问题描述】:
我正在使用 PyQt5 及其编辑器制作 Python GUI。尝试为我使用 styleSheet 玩过的东西添加一些颜色。但是当我在 QMainQindow(图像的左侧和 QDialog(右侧 [期望的外观])中使用它时遇到了不同的结果。就像它对每个其他小部件产生相同的效果一样。
[![在此处输入图片描述][1]][1]
来自 QMainWindow 的代码
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget">
<property name="styleSheet">
<string notr="true">QWidget{
background-color:qlineargradient(spread:repeat, x1:0, y1:1, x2:1, y2:0, stop:0 rgba(39, 21, 103, 255), stop:1 rgba(94, 94, 140, 255))
}
QPushButton{
background-color: qlineargradient(spread:pad, x1:0.915, y1:0.227273, x2:1, y2:0, stop:0 rgba(255, 255, 255, 255), stop:1 rgba(56, 56, 140, 255));
font: 75 8.5pt "Sitka Small";
}
QToolButton{background-color: qlineargradient(spread:pad, x1:0.915, y1:0.227273, x2:1, y2:0, stop:0 rgba(255, 255, 255, 255), stop:1 rgba(56, 56, 140, 255));
font: 75 8.5pt "Sitka Small";
}
QLabel{
color: rgb(255, 255, 255);
}
font: 75 8.5pt "Sitka Small"
</string>
</property>
来自 QDialog 的代码
<property name="windowTitle">
<string>Dialog</string>
</property>
<property name="styleSheet">
<string notr="true">QDialog{
background-color:qlineargradient(spread:repeat, x1:0, y1:1, x2:1, y2:0, stop:0 rgba(39, 21, 103, 255), stop:1 rgba(94, 94, 140, 255))
}
QPushButton{
background-color: qlineargradient(spread:pad, x1:0.915, y1:0.227273, x2:1, y2:0, stop:0 rgba(255, 255, 255, 255), stop:1 rgba(56, 56, 140, 255));
font: 75 8.5pt "Sitka Small";
}
QToolButton{background-color: qlineargradient(spread:pad, x1:0.915, y1:0.227273, x2:1, y2:0, stop:0 rgba(255, 255, 255, 255), stop:1 rgba(56, 56, 140, 255));
font: 75 8.5pt "Sitka Small";
}
QLabel{
color: rgb(255, 255, 255);
}
font: 75 8.5pt "Sitka Small"
</string>
</property>
如何在 QMainWindow 的右侧看到 QDialog 的外观?
【问题讨论】:
-
你的问题是什么?
-
问题是我如何才能看到 QMainWindow 上的 QDialog 中显示的外观。我编辑了帖子,因为问题不够明显。
标签: python python-3.x pyqt pyqt5 qtstylesheets