<div dir="ltr"><div class="gmail_default" style="font-family:tahoma,sans-serif">[I'm sorry if this has been asked before, but I have Googled and can't find it.]</div><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif">In PyQt 5, how are you supposed to actually delete a (dynamically-created) <span style="font-family:monospace,monospace">QDialog</span> once you are done with it, <i>if you cannot create it with <span style="font-family:monospace,monospace">Qt.WA_DeleteOnClose</span></i>?</div><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif">Existing code creates many (modal) dialogs repeatedly, usually calling <span style="font-family:monospace,monospace">exec()</span>.  Some of the calls deliberately do <i>not</i> pass <span style="font-family:monospace,monospace">WA_DeleteOnClose</span> (e.g. I think some places want to access stuff in the dialog after the user has exited it).</div><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif">I get the same dialogs repeatedly created.  Investigating via <span style="font-family:monospace,monospace">QApplication.allWidgets()</span>, I see:</div><div class="gmail_default" style="font-family:tahoma,sans-serif"><ul><li>If a parent was specified, it does get deleted, but not till the parent gets deleted, which is too late (space-wise). <br></li><li>If parent was <span style="font-family:monospace,monospace">None</span>, I'm not even sure when it does get deleted.</li></ul><p>Either way, if I do <i>not</i> specify <span style="font-family:monospace,monospace">WA_DeleteOnClose</span> I want to delete it explicitly when I'm done reading its values or whatever.  In C++ I'd call <span style="font-family:monospace,monospace">delete</span> explicitly.  What should I do from PyQt/Python?  <span style="font-family:monospace,monospace">del</span>??  <span style="font-family:monospace,monospace">.deleteLater()</span>??<br></p></div><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>