Important: Please read the Qt Code of Conduct -

Transparent Widgets not working

  • Hello community,

    I can't get my widgets to be transparent, always end up with a black or fading to black background
    I'm on Gnome 2.28.2, I'm pretty sure it works on Windows though.

    from PySide import QtGui, QtCore
    widget = QtGui.QWidget()

    Any solution for that ?


  • Lifetime Qt Champion

    Can you try with
    widget.setAttribute(Qt.WA_NoSystemBackground, True) also ?

    I assume you mean fully transparent and not faded color/semi. ?

  • Well, for the example sake we're trying fully transparent just to demonstrate that transparency doesn't work on some platforms.
    But my goal is to have a semi-transparent window (that requires custom painting) that's why I said fading to black since opacity is replaced by black.

    Even with the extra line it's still black, I've tested on Windows and it's black too ...

    But if I do :


    it works on Windows but not on Gnome ... but that's not what I want anyway (This will affect the entire window not only the background)

    I need a way to set opacity that is going to work on all platforms or at least the main ones.

  • I have an other piece of code that represent exactly what I'm trying to do.

    form PySide import QtGui, QtCore
    class RoundWindow(QtGui.QWidget):
        def __init__(self):
            super(RoundWindow, self).__init__()
        def initUI(self):
        def sizeHint(self):
            return QtCore.QSize(300,300)
        def paintEvent(self, event):
            qp = QtGui.QPainter()
            qp.setBrush(QtGui.QColor(255, 0, 0, 127));
            qp.drawEllipse(0, 0, 300, 300);
    rw = RoundWindow()

    This works perfectly on Windows, but no luck on Gnome, I have a black square with my red circle

Log in to reply