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

List:       pykde
Subject:    Re: [PyKDE] Issue with QDialog and lifetime
From:       Toby Dickenson <tdickenson () geminidataloggers ! com>
Date:       2005-05-26 12:51:26
Message-ID: 200505261351.26217.tdickenson () geminidataloggers ! com
[Download RAW message or body]

On Thursday 26 May 2005 13:16, Giovanni Bajo wrote:
> Toby Dickenson <tdickenson@devmail.geminidataloggers.co.uk> wrote:
> 
> > > class QDialog2(QDialog):
> > > def __init__(self, parent=0, name=0, modal=False, flags=0)
> > > QDialog.__init__(self, parent, name, modal, flags |
> > > Qt.WDestructiveClose)
> 
> Actually, for my project, I'm better off with:
> 
> class QDialog2(QDialog):
> def __init__(self, parent=0, name=0, modal=False, flags=0)
> if modal:
> flags |= Qt.WDestructiveClose
> QDialog.__init__(self, parent, name, modal, flags)
> 
> Becuase modeless dialogs really need their ownership to be transferred to
> the parent.

modeless..... ahh...... completely different. You are right WDestructiveClose 
is the right tool for that job.

> > That works, but Im not sure I would recommend it. It leads to a bigger
> change
> > should you ever need to access the dialog after it has been closed. (or,
> more
> > likely, the value of a control widget on the dialog)
> 
> 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()


-- 
Toby Dickenson

____________________

Important Notice:

This email and any attachments are confidential and may contain trade secrets or be \
legally privileged. If you have received this email in error you must not use, rely \
upon, disclose, copy or distribute the contents. Please reply to the sender so that \
proper delivery can be arranged and delete the email from your computer. Gemini Data \
Loggers monitor incoming and outgoing email to ensure satisfactory customer service, \
maintain company security and prevent abuse of their email system. However, any views \
expressed in this email are not necessarily those of Gemini and Gemini cannot be held \
responsible for the content. Gemini makes best efforts to ensure emails are virus \
free; however you are advised to carry out your own checks. Gemini does not accept \
responsibility for any damage resulting from email viruses. ____________________

_______________________________________________
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