设置透明主窗口 [英] Setting a transparent main window

查看:36
本文介绍了设置透明主窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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}")

推荐答案

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

you must set new attribute for MainWindow object as below:

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

这篇关于设置透明主窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆