Transparent Widgets not working
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() widget.setAttribute(QtCore.Qt.WA_TranslucentBackground) widget.show()
Any solution for that ?
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__() self.initUI() def initUI(self): self.setWindowFlags(QtCore.Qt.FramelessWindowHint) self.setAttribute(QtCore.Qt.WA_TranslucentBackground) def sizeHint(self): return QtCore.QSize(300,300) def paintEvent(self, event): qp = QtGui.QPainter() qp.begin(self) qp.setRenderHint(QtGui.QPainter.Antialiasing); qp.setPen(QtCore.Qt.NoPen); qp.setBrush(QtGui.QColor(255, 0, 0, 127)); qp.drawEllipse(0, 0, 300, 300); qp.end() rw = RoundWindow() rw.show()
This works perfectly on Windows, but no luck on Gnome, I have a black square with my red circle