Reputation: 305
I'm doing an addon for Blender and I'm using PySide2. I was able to remove the Window Title and appear only the content of the window. I inserted an animated gif inside a QFrame and changed the border of it. The problem is that the container still have its sharp borders appearing.
Is there any way to change a QLayout style? I wish to add corners to the QLayout or set it to transparent instead of white.
Here is my code:
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)
Upvotes: 1
Views: 1199
Reputation: 243897
You have to make the window transparent:
self.setAttribute(QtCore.Qt.WA_TranslucentBackground, True)
self.setStyleSheet("""
QWidget{
background: transparent;
}
QFrame{
border-style: solid;
border-color: rgba(55, 55, 55, 255);
border-width: 3px;
border-radius: 30px;
background-color: rgba(55, 55, 55, 255);
}
""")
Note: The layout is not a graphic element so it cannot be made transparent, what has to be made transparent is the container.
Upvotes: 2