【发布时间】:2019-12-26 20:03:39
【问题描述】:
我正在为 Blender 做一个插件,我正在使用 PySide2。我能够删除窗口标题并仅显示窗口的内容。我在 QFrame 中插入了一个动画 gif 并更改了它的边框。问题是容器仍然出现尖锐的边界。
有什么方法可以改变 QLayout 的样式吗? 我希望为 QLayout 添加角或将其设置为透明而不是白色。
这是我的代码:
def __init__(self, parent=None):
super(Ui_Form, self).__init__(parent)
#size of the container of gif
self.size = QtCore.QSize(160, 100)
self.pixel = QtGui.QMovie(
'/home/mateus/Documents/Blender Projects/blender_pyside2_example-master/gui/img.gif')
self.pixel.setScaledSize(self.size)
#size of the window
self.setFixedSize(160, 100)
#style of with rounded corners
self.setStyleSheet("""
QFrame{
border-style: solid;
border-color: rgba(55, 55, 55, 255);
border-width: 3px;
border-radius: 10px;
background-color: rgba(55, 55, 55, 255);
}
""")
self.label = QtWidgets.QLabel()
self.label.setMovie(self.pixel)
self.pixel.start()
self.label.show()
layout = QtWidgets.QVBoxLayout()
layout.setMargin(0)
#attach gif to layout
layout.addWidget(self.label)
self.unsetCursor()
self.setLayout(layout)
【问题讨论】: