Is it possible to initialize and delete QApplication instances many times?
The following is a sample code:
while some_condition:
app = QApplication(sys.argv)
some_actions
del app
I tried, but it seemed impossible.
If I want to initialize and delete QApplication instances many times in a single file, how can I do that?
UPDATE
Here I want to use QtWebKit to crawl some web pages and it could parse AJAX automatically. But when I used QApplication(sys.argv).exec_() to start the event loop, I couldn’t add new urls in the code because it entered a loop. So I think, if I could initialize and delete the class many times, then I could add new urls to crawl. But it failed. I don’t understand that why the event loop seemed still exist even after I delete the instance.
When I use QApplication(sys).processEvents(), I find these problems could be solved properly.
Sorry for my poor expression.
Use
QApplication(sys.argv).processEvents()instead ofQApplication(sys.argv).exec_()