[PyQt] How to explicitly delete a QDialog when finished with it?

J Barchan jnbarchan at gmail.com
Thu Jul 12 11:07:41 BST 2018


[I'm sorry if this has been asked before, but I have Googled and can't find
it.]

In PyQt 5, how are you supposed to actually delete a (dynamically-created)
QDialog once you are done with it, *if you cannot create it with
Qt.WA_DeleteOnClose*?

Existing code creates many (modal) dialogs repeatedly, usually calling
exec().  Some of the calls deliberately do *not* pass WA_DeleteOnClose
(e.g. I think some places want to access stuff in the dialog after the user
has exited it).

I get the same dialogs repeatedly created.  Investigating via
QApplication.allWidgets(), I see:

   - If a parent was specified, it does get deleted, but not till the
   parent gets deleted, which is too late (space-wise).
   - If parent was None, I'm not even sure when it does get deleted.

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()??

-- 
Kindest,
Jonathan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20180712/f90e2bdc/attachment.html>


More information about the PyQt mailing list