Setting a transparent main window

醉酒当歌 提交于 2020-08-24 07:14:17

问题


How to set main window background transparent on QT? Do I need an attribute or a style?
I've tried setting the opacity, but it didn't work for me.

app.setStyleSheet("QMainWindow {opacity:0}")

回答1:


you must set new attribute for MainWindow object as below:

class Main(QtGui.QMainWindow):
      def __init__(self):
          self.setAttribute(Qt.WA_TranslucentBackground)



回答2:


Just use the windowOpacity property:

http://doc.qt.io/qt-4.8/qwidget.html#windowOpacity-prop



来源:https://stackoverflow.com/questions/14943142/setting-a-transparent-main-window

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!