Toby Dickenson <[EMAIL PROTECTED]> wrote:
> On Wednesday 25 May 2005 16:13, Giovanni Bajo wrote:
>
>> So, I don't see any easy way to take care of this automatically. One
>> has to remember to manually destroy the dialog calling deleteLater
>
> Yes. My PyQt idiom for running a dialog is:
>
>     dlg = WhateverDlg(parent)
>     try:
>         ok = dlg.exec_loop()
>         if ok:
>             # do things in here maybe
>     finally:
>         dlg.deleteLater()
>
> which isnt so bad.

I now see that exec_loop() returns the dialog exit code. I thought one had to
call result() to acquire that. This said, if you don't need to access the
dialog itself after it's been closed, it is sufficient to do:

dlg = WhateverDlg(parent)
dlg.setWFlags(Qt.WDestructiveClose)
ok = dlg.exec_loop()
if ok:
   # do things

which means that you can have:

class QDialog2(QDialog):
   def __init__(self, parent=0, name=0, modal=False, flags=0)
       QDialog.__init__(self, parent, name, modal, flags |
Qt.WDestructiveClose)

Giovanni Bajo

_______________________________________________
PyKDE mailing list    PyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde

Reply via email to