[PyKDE] Using QObject.disconnect

Sergey ANIKIN san at nnov.matra-dtv.fr
Thu Sep 12 17:53:01 BST 2002


Dear Phil,

Thank you for your assistance!

Exactly, the problem resulted from passing different QObjects to 
"connect" and "disconnect".
Just a little detail: "d" and "self" referred to the same PyObject, "s" 
(Selection object) had different values. I understood this only after 
creating a simple example which worked well. :)

Best regards,
Sergey

Phil Thompson wrote:

> 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
>
> _______________________________________________
> PyKDE mailing list    PyKDE at mats.gmd.de
> http://mats.gmd.de/mailman/listinfo/pykde
>
>





More information about the PyQt mailing list