[PyKDE] Using QObject.disconnect
Phil Thompson
phil at river-bank.demon.co.uk
Thu Sep 12 16:30:00 BST 2002
Sergey ANIKIN wrote:
> I have the following QDialog-based Python class:
>
> class SuperDialog(QDialog) :
> ...
> def onSelection(self) :
> <some actions>
>
> def onOk(self) :
> ...
> s = desktop.getSelection()
> QObject.disconnect(s, SIGNAL('selectionChanged()'),
> self.onSelection)
>
> After SuperDialog object has been created, I connect its onSelection
> method to some signal generated by C++ object Selection:
>
> d = SuperDialog(desktop)
> s = desktop.getSelection()
> QObject.connect(s, SIGNAL('selectionChanged()'), d.onSelection)
>
> It works just fine until I press OK button. When onOk method tries to
> disconnect this dialog from Selection's signal, I get the follwoing
> message:
>
> File "SuperGUI.py", line 184, in onOk
> QObject.disconnect(s, SIGNAL('selectionChanged()'), self.onSelection)
> RuntimeError: Slot hasn't been connected
> Unfortunately, PyQt docs provide very poor description of "disconnect"
> usage.
> Therefore, could anybody give me an advice how to disconnect dialog's
> slot from its onOk method? Maybe Phil? ;)
It looks like you are trying to use it correctly. The first thing to
check is that self.onSelection and d.onSelection are the same Python
object. If they are then send me a short, but complete, example that
demonstrates the problem. I don't think QObject.disconnect() is heavily
used, so it may be a PyQt bug.
Phil
More information about the PyQt
mailing list