[prev in list] [next in list] [prev in thread] [next in thread]
List: pykde
Subject: Re: [PyQt] How to explicitly delete a QDialog when finished with it?
From: J Barchan <jnbarchan () gmail ! com>
Date: 2018-07-12 12:12:35
Message-ID: CABz3M_9esr8W1Z_ESc+AQ6E1hQ4FTygjvKs3qW5zLywfrLKBzg () mail ! gmail ! com
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
On 12 July 2018 at 11:47, Florian Bruhin <me@the-compiler.org> wrote:
> Hey,
>
> On Thu, Jul 12, 2018 at 11:07:41AM +0100, J Barchan wrote:
> > Either way, if I do *not* specify
>
> WA_DeleteOnClose I want to delete it
> > explicitly when I'm done reading its values or whatever. In C++ I'd call
> > delete explicitly. What should I do from PyQt/Python? del??
> > .deleteLater()??
>
> I just use obj.deleteLater(). There's also sip.delete(obj) if you really
> need something gone immediately, but I almost never use that.
>
> Florian
>
> --
> https://www.qutebrowser.org | me@the-compiler.org (Mail/XMPP)
> GPG: 916E B0C8 FD55 A072 | https://the-compiler.org/pubkey.asc
> I love long mails! | https://email.is-not-s.ms/
>
Thanks, Florian, I'll give deleteLater() a go and test.
Let me ask you one other question. I have a lot of these to deal with. I
*suspect* that some of those which do not presently pass
WA_DeleteOnClose to the constructor do not actually access the dialog after
exec(). *All* my dialogs are derived from my own base class. For
simplicity/clarity, I'd like to make my base class unconditionally
call super().__init__(parent,
Qt.WA_DeleteOnClose). Then those callers which do *not* want auto-delete
can explicitly go self.setWindowFlags(self.windowFlags() &
~Qt.WA_DeleteOnClose) immediately *after* construction. I think this will
give easiest default behaviour for my code. The question is: is it OK to
switch off WA_DeleteOnClose after construction, or do you think there is
something which needs to know about this flag at construction-time only,
and afterward is too late to switch off??
--
Kindest,
Jonathan
[Attachment #5 (text/html)]
<div dir="ltr"><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div><div \
class="gmail_extra"><br><div class="gmail_quote">On 12 July 2018 at 11:47, Florian Bruhin <span \
dir="ltr"><<a href="mailto:me@the-compiler.org" \
target="_blank">me@the-compiler.org</a>></span> wrote:<br><blockquote class="gmail_quote" \
style="margin:0px 0px 0px 0.8ex;border-left:1px solid \
rgb(204,204,204);padding-left:1ex">Hey,<br> <br>
On Thu, Jul 12, 2018 at 11:07:41AM +0100, J Barchan wrote:<br>
> Either way, if I do *not* specify <div \
style="font-family:tahoma,sans-serif;display:inline" \
class="gmail_default"></div>WA_DeleteOnClose I want to delete it<br> <span \
class="gmail-">> explicitly when I'm done reading its values or whatever. In C++ \
I'd call<br> > delete explicitly. What should I do from PyQt/Python? del??<br>
> .deleteLater()??<br>
<br>
</span>I just use obj.deleteLater(). There's also sip.delete(obj) if you really<br>
need something gone immediately, but I almost never use that.<br>
<span class="gmail-HOEnZb"><font color="#888888"><br>
Florian<br>
<br>
-- <br>
<a href="https://www.qutebrowser.org" rel="noreferrer" \
target="_blank">https://www.qutebrowser.org</a> | <a \
href="mailto:me@the-compiler.org">me@the-compiler.org</a> (Mail/XMPP)<br>
GPG: 916E B0C8 FD55 A072 | <a href="https://the-compiler.org/pubkey.asc" rel="noreferrer" \
target="_blank">https://the-compiler.org/<wbr>pubkey.asc</a><br>
I love long mails! | <a href="https://email.is-not-s.ms/" rel="noreferrer" \
target="_blank">https://email.is-not-s.ms/</a><br> </font></span></blockquote></div></div><div \
class="gmail_extra"><br></div><div class="gmail_extra"><div \
style="font-family:tahoma,sans-serif" class="gmail_default">Thanks, Florian, I'll give \
<span style="font-family:monospace,monospace">deleteLater()</span> a go and test.</div><div \
style="font-family:tahoma,sans-serif" class="gmail_default"><br></div><div \
style="font-family:tahoma,sans-serif" class="gmail_default">Let me ask you one other \
question. I have a lot of these to deal with. I <i>suspect</i> that some of those which do \
not presently pass <div style="display:inline" class="gmail_default"></div><span \
style="font-family:monospace,monospace">WA_DeleteOnClose</span> to the constructor do not \
actually access the dialog after <span style="font-family:monospace,monospace">exec()</span>. \
<i>All</i> my dialogs are derived from my own base class. For simplicity/clarity, I'd \
like to make my base class unconditionally call <span \
style="font-family:monospace,monospace">super().__init__(parent, Qt.WA_DeleteOnClose)</span>. \
Then those callers which do <i>not</i> want auto-delete can explicitly go <span \
style="font-family:monospace,monospace">self.setWindowFlags(self.windowFlags() & \
~Qt.WA_DeleteOnClose)</span> immediately <i>after</i> construction. I think this will give \
easiest default behaviour for my code. The question is: is it OK to switch off <span \
style="font-family:monospace,monospace">WA_DeleteOnClose</span> after construction, or do you \
think there is something which needs to know about this flag at construction-time only, and \
afterward is too late to switch off??<br></div><br><br clear="all"><br>-- <br><div \
class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><span \
style="font-family:tahoma,sans-serif">Kindest,</span></div><div><span \
style="font-family:tahoma,sans-serif">Jonathan</span></div></div></div></div></div> \
</div></div>
[Attachment #6 (text/plain)]
_______________________________________________
PyQt mailing list PyQt@riverbankcomputing.com
https://www.riverbankcomputing.com/mailman/listinfo/pyqt
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic