On Tue Feb 17 14:47:45 GMT 2009, Gabriele Visconti wrote: > 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.
One thing to check before trying this is that it is actually possible to make windows transparent on your system. Lots of people want to try out the window opacity feature without realising that you need to be running a window manager that supports it, amongst other things: http://doc.trolltech.com/4.4/qwidget.html#windowOpacity-prop In addition, you need to make sure it is enabled. If you already see other applications doing things with transparency then it probably is possible to use PyQt for this as well. One point to make about the code is that events are not signals: self.connect(self, SIGNAL("QMouseEvent()"), self.Opacity) You need to reimplement the event handler related to the event you want to deal with. So, in this case, you would reimplement QWidget.moveEvent() in your subclass, as Christophe explains in another message. (The mouse event handlers are a distraction in this particular situation.) So, the method/slot you define needs to be written as an event handler (again, see Christophe's message) and won't work as it is: def Opacity(self): while QMouseEvent(Qt.LeftButton): self.setWindowOpacity(0.5) else: pass It's interesting to look at this method because I think it says something about how you expected events to be handled. If you don't mind me asking, have you used other frameworks or toolkits extensively? David _______________________________________________ PyQt mailing list [email protected] http://www.riverbankcomputing.com/mailman/listinfo/pyqt
