[Tutor] Basic QT query
Dave S
pythontut at pusspaws.net
Fri Jul 14 20:21:07 CEST 2006
Hi all,
I am trying to get to grips with QT, putting a friendly face on some of my
apps :) Its early days and my first attempt but I expected the following to
print 'hi it works' every second.
There problem I am stuck with is ...
The debugged program raised the exception unhandled RuntimeError
"underlying C/C++ object has been deleted" At line 24
ie "self.timer = self.startTimer(1000)". First of all I did not have an
assignment ie I just had "self.startTimer(1000)" realising Python would
garbage collect I added an assignment but still the same problem.
Also I am struggling with "QObject.connect(self.tickerevent,
PYSIGNAL("ticker"), self.hello)" I am unsure of what the source of the
connect is - I suspect my guess of self.tickerevent is wrong. The source of
the event should be PYSIGNAL("ticker") ?
Any ideas or suggestions much appreciated
Cheers
Dave
** MY QT MASTERPIECE :) **
import sys
from qt import *
from frm_livedata import frm
class Ticker(QObject):
def __init__(self):
QObject.__init__, (self)
self.timer = self.startTimer(1000)
def timerEvent(self, ev):
self.emit(PYSIGNAL("ticker")())
QObject.connect(self.tickerevent, PYSIGNAL("ticker"), self.hello)
def hello():
print 'hi it works'
x=Ticker()
if __name__ == '__main__':
app = QApplication(sys.argv)
win = frm()
app.setMainWidget(win)
win.show()
QObject.connect(app, SIGNAL('lastWindowClosed()'),app, SLOT('quit()'))
app.exec_loop()
More information about the Tutor
mailing list