I ran into a strange corner case when attempting to render a fully transparent widget in PySide.
If I call setMask with a QBitmap that is filled with Qt.color0, it makes the widget completely opaque (rather than completely transparent, as I would expect).
Putting in a single pixel of Qt.color leads to the expected behavior: the widget becomes completely transparent other than that single pixel.
Below is a minimal example. Changing the variable single_pixel to True fills in the top left pixel, which causes the mask to start working as expected.
Any ideas what's going on here?
import sys
from PySide import QtCore, QtGui
app = QtGui.QApplication(sys.argv)
widget = QtGui.QWidget()
widget.resize(200, 200)
widget.show()
bitmap = QtGui.QBitmap(widget.size())
bitmap.clear()
single_pixel = False
if single_pixel:
painter = QtGui.QPainter()
painter.begin(bitmap)
painter.setPen(QtCore.Qt.color1)
painter.drawPoint(0,0)
painter.end()
widget.setMask(bitmap)
sys.exit(app.exec_())