Reputation:
Hi Everybody i'm newbie in almost every technology that i'm about to talk you about below ,
i'm launching an QApplication
with sys.exit(qapp.exec_())
(required because i'm using a QWebView
in my python class) and everything's fine with that except that the application does not quit by its own after execution and this is causing a problem when i call this Qapplication through a REST Django webservice (the server won't quit loading) , so i was wondering if there's any solution for that , thank you ,
I was thinking of performing a SIGTSTP (ctrl + z) with python after launching the app , is this a practical solution?
Here is a portion of the code
def main():
import sys
qApp = QtGui.QApplication(sys.argv)
myappWebView = myappWebView()
myappWebView.load('http://website.com')
myappWebView.show()
sys.exit(qApp.exec_())
if __name__ == "__main__":
main()
A window is being launched whenever i execute this and the linux console won't prompt me for a new command and is stuck until i close the window manually .
Upvotes: 2
Views: 6966
Reputation: 29886
You can quit the application when the page has finished loading:
myappWebView.loadFinished.connect(qApp.quit)
Or if the page has some javascript that needs time to execute, you can use a timer to delay the application closing:
timer = QTimer()
timer.setInterval(2000) # 2 seconds
myappWebView.loadFinished.connect(timer.start)
timer.timeout.connect(qApp.quit)
(Or you can choose a more complicated and maybe more accurate method: How to know when a web page is loaded when using QtWebKit? ).
Upvotes: 0
Reputation: 9502
It's hard to answer without seeing code, but I think you can call QCoreApplication.exit()
when job is done.
Upvotes: 2