我在Windows 10机器上写了一个程序,并将代码通过SSH传入到运行Raspbian的Raspberry Pi机器上。当把一些样式表应用到某些对象上时,它们在Windows上看起来很好,但某些元素在Linux机器上却没有被接收到。
我创建了一个测试程序来显示发生了什么。
我在Raspbian机器上遇到的唯一问题就是背景没有被填充。字体大小和颜色的属性都能正常显示。我试着用 .autoFillBackground()
和 .setAttribute(Qt.WA_StyledBackground)
但都没有得到任何结果。
我也试过结合使用 QPushButton::active:
和 background:
background-color:
没有任何运气。
有什么想法吗?
EDIT:PySide2是使用安装。
apt-get install python3-pyside2.qt3dcore python3-pyside2.qt3dinput python3-pyside2.qt3dlogic python3-pyside2.qt3drender python3-pyside2.qtcharts python3-pyside2.qtconcurrent python3-pyside2.qtcore python3-pyside2.qtgui python3-pyside2.qthelp python3-pyside2.qtlocation python3-pyside2.qtmultimedia python3-pyside2.qtmultimediawidgets python3-pyside2.qtnetwork python3-pyside2.qtopengl python3-pyside2.qtpositioning python3-pyside2.qtprintsupport python3-pyside2.qtqml python3-pyside2.qtquick python3-pyside2.qtquickwidgets python3-pyside2.qtscript python3-pyside2.qtscripttools python3-pyside2.qtsensors python3-pyside2.qtsql python3-pyside2.qtsvg python3-pyside2.qttest python3-pyside2.qttexttospeech python3-pyside2.qtuitools python3-pyside2.qtwebchannel python3-pyside2.qtwebsockets python3-pyside2.qtwidgets python3-pyside2.qtx11extras python3-pyside2.qtxml python3-pyside2.qtxmlpatterns python3-pyside2uic
从... https:/forum.qt.iotopic112813在raspberry-pi上安装pyside2。
import sys
from PySide2.QtWidgets import *
from PySide2.QtGui import *
from PySide2.QtCore import *
class Window(QWidget):
def __init__(self):
QWidget.__init__(self)
self.btn1 = QPushButton("Button 1")
self.btn2 = QPushButton("Button 2")
self.btn1.setStyleSheet("""background: blue; color: yellow; border: 3px solid black""")
self.btn2.setStyleSheet("background: red; color: white; font-size: 30px;")
layout = QVBoxLayout()
layout.addWidget(self.btn1)
layout.addWidget(self.btn2)
self.setLayout(layout)
app = QApplication(sys.argv)
window = Window()
window.show()
app.exec_()