[PyQt] problem with main window opacity (signal&slot)

Christophe Diericx christophe.diericx at natuurpunt.be
Tue Feb 17 16:20:46 GMT 2009


I'd do something like the following: forget about the signals, but just
reimplement the "moveEvent" for the widget.

Something like this:

def moveEvent(self, event):
	if self.isVisible():
		self.setWindowOpacity(0.5)
	QTimer.singleShot(1000, functools.partial(self.setWindowOpacity,
1))

Complete code example: http://paste.pocoo.org/show/104298/

 
________________________________

Van: pyqt-bounces at riverbankcomputing.com
[mailto:pyqt-bounces at riverbankcomputing.com] Namens Gabriele Visconti
Verzonden: dinsdag 17 februari 2009 15:48
Aan: pyqt at riverbankcomputing.com
Onderwerp: [PyQt] problem with main window opacity (signal&slot)


Hello everybody,

I'm experimenting with PyQt, trying to learn it, and I'm a bit stuck
with Signals and Slots. I don't usually like just to repeat the examples
you find in tutorials and guides because I think it's more useful for
learning to experiment concepts by yourself. Tutorials usually teach you
doing the most basic things which, once learnt, nearly never apply to
your personal situation or usage.
What I want to do is to replicate the KDE effect, you know that when you
grab a window and drag it around the window temporary becomes
transparent (low alpha). 
I found the relevant Qt class which is setWindowOpacity(), I tried to
build a signal-slot system which when the left mouse is pressed on the
main widget (i.e. for dragging it around) the widget will become
transparent.
I can't obtain this effect. There's no traceback error it simply does
nothing. Of course I missed something important. Any suggestion or help
to solve my problem.
Thanks a lot.
Here below my code.



More information about the PyQt mailing list