[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 10:24:28
Message-ID: 00cd01c561dd$19043520$2d402597 () bagio
[Download RAW message or body]

Toby Dickenson <tdickenson@devmail.geminidataloggers.co.uk> 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
[prev in list] [next in list] [prev in thread] [next in thread] 

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