[PyKDE] Auto-connecting Slots
ismail at uludag.org.tr
Fri Jan 27 23:39:31 GMT 2006
Cts 28 Oca 2006 00:46 tarihinde, Phil Thompson şunları yazmıştı:
> On Friday 27 January 2006 8:10 pm, Patrick K. O'Brien wrote:
> > Phil Thompson wrote:
> > > Tonight's PyQt4 snapshot implements Torsten's suggestion for using a
> > > decorator to control which signal/slot connections are made when pyuic4
> > > auto-connects.
> > >
> > > The problem is best demonstrated by QSpinBox which emits
> > > valueChanged(QString) and valueChanged(int). Defining an auto-connect
> > > method
> > > on_spinbox_valueChanged means that the method is connected to both
> > > signals and so gets invoked twice. Until now the method had to look at
> > > the type of the argument and just return if it was the one it didn't
> > > want.
> > >
> > > The QtCore.signature() decorator takes a single argument which is, in
> > > effect, the C++ signature of the method which tells the auto-connect
> > > code which signal to connect. For example...
> > >
> > > @QtCore.signature("on_spinbox_valueChanged(int)")
> > > def on_spinbox_valueChanged(self, value):
> > > # value will only ever be an integer.
> > Any chance we could get an easier syntax, such as:
> > @qtsig(int)
> > def on_spinbox_valueChanged(self, value):
> I want to keep it generic in case some other uses pop up.
> At the very least your example would have to be @QtCore.qtsig("int")
@QtCore.signature("int") is better imho.
More information about the PyQt