设置透明主窗口

pun*_*her 7 python qt pyqt

如何在QT上设置主窗口背景透明?我需要属性还是样式?
我已经尝试设置不透明度,但它对我不起作用.

app.setStyleSheet("QMainWindow {opacity:0}")
Run Code Online (Sandbox Code Playgroud)

omi*_*mid 11

您必须为MainWindow对象设置新属性,如下所示:

class Main(QtGui.QMainWindow):
      def __init__(self):
          self.setAttribute(Qt.WA_TranslucentBackground)
Run Code Online (Sandbox Code Playgroud)