Answer the question
In order to leave comments, you need to log in
What to use in Qt close() or destroy()?
Hello!
Tell me what to use to close windows in Qt? I use both functions at once to completely close the window
self.close() and self.destroy()
Why do I do this:
1) I wrote an application in which a dialog box is called, and when a button is clicked, a table of 1,000,000 elements is built. So if you use just close(), then when you call this dialog box again, the table remains full! (That is, the old filled table is saved)
The second point comes out of this
2) When using only close(), the memory is not released. A table of 1,000,000 items remains in memory.
When using self.close() and self.destroy() at the same time, there are no such problems, so I now close the entire window in this way.
Dedicate the ignoramus please, am I doing the right thing?
Answer the question
In order to leave comments, you need to log in
The idea is this:
- show the client a data entry form
- the client fills out this form and clicks OK
- you process the signal to close the window and hide it
- then, the metadata from the window has not gone away, you can continue to use it. (well, for example, it was the program settings window and you save data to disk).
- as soon as you decide that no data from this window is needed anymore, then feel free to destroy it.
Have you tried QTableWidget.clear() or QTableWidget.clearContents() ?
And then self.close() ?
In this order, it will be more logical to close the table.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question