PyQt - Transparent Background

I am trying to make the background of my window transparent. But under the widgets that are on it, I see parts of my desktop. Now I have this in the constructor:

    self.setFocusPolicy(Qt.StrongFocus)
    self.setAttribute(Qt.WA_QuitOnClose,True)

    self.setBackgroundRole(QtGui.QPalette.Base)
    self.setAttribute(Qt.WA_NoSystemBackground)
+5
source share
3 answers

In response to gs, this faq explains why (before Qt 4.5) you cannot achieve this:

Frequently Asked Questions Link:

There is no direct support for partial transparency, where the window is transparent and the widgets on it are not in Qt.

, PyQt Qt 4.4 , . gs other answer, about setAutoFillBackground (True) , -, .

. Qt.WA_NoSystemBackground, , , :

Qt:: WA_NoSystemBackground

, , , . : WA_OpaquePaintEvent, (, , . "" , ). / .

+2

this:

Qt 4.5, , .

, Qt:: WA_TranslucentBackground setAttribute() , , .

PyQt Qt 4.4, , .

+4

Try this for your widgets:

widget.setAutoFillBackground(True)

I think you could also install it in Qt Designer.

+2
source

All Articles