QCoreApplication will not quit

A

Adrian Casey

Can someone please explain why this simple PyQt4 application never exits?

#!/usr/bin/env python
from PyQt4 import QtCore
import sys
class foo(QtCore.QObject):
def __init__(self, parent):
QtCore.QObject.__init__(self, parent)
self.parent = parent
self.end_job()

def end_job(self):
QtCore.QCoreApplication.quit()

if __name__ == '__main__':
app = QtCore.QCoreApplication(sys.argv)
myFoo = foo(parent=None)
sys.exit(app.exec_())

This is just a very simple, cut-down example to demonstrate a problem I have
with an application I am writing. If I call
QCoreApplication.hasPendingEvents(), the result is always True. Even if I
call QCoreApplication.processEvents(), the application still does not quit.
It just hangs forever.

I'd appreciate some help in finding out how to make it quit.

Thanks.
Adrian.
 
D

Dennis Lee Bieber

Can someone please explain why this simple PyQt4 application never exits?

#!/usr/bin/env python
from PyQt4 import QtCore
import sys
class foo(QtCore.QObject):
def __init__(self, parent):
QtCore.QObject.__init__(self, parent)
self.parent = parent
self.end_job()

def end_job(self):
QtCore.QCoreApplication.quit()

if __name__ == '__main__':
app = QtCore.QCoreApplication(sys.argv)
myFoo = foo(parent=None)
sys.exit(app.exec_())
Uhm... Could it be because you've shut down the application before
ever starting it?

Note that your __init__() method -- invoked when you create "myFoo",
ENDS with a call to end_job() which invokes the framework quit() method.

THEN after all this framework shut down, you invoke the app.exec_()
on a framework that has nothing left to run?
 
A

Adrian Casey

Dennis said:
Uhm... Could it be because you've shut down the application before
ever starting it?

Note that your __init__() method -- invoked when you create "myFoo",
ENDS with a call to end_job() which invokes the framework quit() method.

THEN after all this framework shut down, you invoke the app.exec_()
on a framework that has nothing left to run?
Thanks Dennis. I should have seen that!

Cheers.
Adrian.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top