[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: [PyKDE] Issue with QDialog and lifetime
From:       "Giovanni Bajo" <rasky () develer ! com>
Date:       2005-05-26 13:09:36
Message-ID: 01ec01c561f4$2a7592b0$bf03030a () trilan
[Download RAW message or body]

Toby Dickenson <tdickenson@geminidataloggers.com> wrote:

>> Notice that WDestructiveClose does not collect the Python object (of
>> course). So you can easily do something like:
>>
>> class MyDialog(QDialog2):
>>      # bla bla
>>
>>      def accept(self):
>>          self.value = self.lineedit.text()
>>
>> and then later access that string.
>
> But then you need to have a different method to access the text before and
> after the close. I would rather:
>
> dlg = WhateverDlg(parent)
>     dlg.lineedit.setText('foo')
> try:
> ok = dlg.exec_loop()
> if ok:
> print dlg.lineedit.text()
> finally:
> dlg.deleteLater()
>
> plus you avoid the need for that boring code in accept()

That's right, I would rather that, but alas there is no perfect solution.
The thing I like most about this is that there can't be a programming error.
Either you get an exception because you forgot to save things in accept(),
or it works, period. Having a large codebase, I prefer things that either
crash or work perfectly, without having to go hunting memory leaks
everywhere :)
-- 
Giovanni Bajo

_______________________________________________
PyKDE mailing list    PyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic