(I'm using PySide, but I think the answer would be the same/similar for any language bindings).
I'm trying to take the shaped clock example, located here, and cause the face of the clock (circle) to be transparent so that all I see are the clock hands and minute ticks. As is, when the example runs, it looks like this. I'm using Windows 7.
So far, I've tried the following (in the constructor):
self.setAttribute(QtCore.Qt.WA_TranslucentBackground)
self.setAttribute(QtCore.Qt.WA_NoSystemBackground)
self.setWindowOpacity(0.5)
Widgets are the primary elements for creating user interfaces in Qt. Widgets can display data and status information, receive user input, and provide a container for other widgets that should be grouped together. A widget that is not embedded in a parent widget is called a window.
Got it!
This is from the original example code (constructor):
...
self.setWindowFlags(self.windowFlags() | QtCore.Qt.FramelessWindowHint)
...
Here is the modified (and working per my question) version:
...
self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
self.setAttribute(QtCore.Qt.WA_TranslucentBackground)
...
Removing the self.windowFlags()
was the part I was missing. (I'm not exactly sure why I needed to remove this or why it was there to begin with... still much to learn).
If I remember correctly, you should have set its stylesheet also:
self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
self.setAttribute(QtCore.Qt.WA_TranslucentBackground)
self.setStyleSheet("background:transparent;")
Hope that helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With