python QThread.run 参数 - 版本之间发生变化?
在我的代码(python2.6,PyQt4)中,我做了这样的事情:
def myRun():
doStuff
thread = QtCore.QThread()
thread.run = myRun
thread.start()
在我的gentoo机器上,这工作得很好。在 ubunut(9.10,Karmic Koala)上它不起作用,它说: 类型错误:myRun() 不接受参数(给定 1)
QT 中是否发生了变化?我怎样才能使这在两台机器上都工作?
谢谢! 内森
In my code (python2.6, PyQt4) I do something like this:
def myRun():
doStuff
thread = QtCore.QThread()
thread.run = myRun
thread.start()
On my gentoo machine, this works perfectly. On a ubunut (9.10, Karmic Koala) it does not work, it says:
Type Error: myRun() takes no arguments (1 given)
Did something change in QT? How can I make this work on both machines?
Thanks!
Nathan
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定那是如何运作的;你应该继承 QThread 并重写 run() 方法。 “不带参数”错误是因为 QT 运行时试图将“self”作为类方法的第一个参数传递。以下内容更接近您的需要:
更新:与原始内容更加匹配。
I'm not sure how that ever worked; you're supposed to subclass QThread and override the run() method. The "takes no arguments" error is because the QT runtime is trying to pass "self" as the first argument of a class method. The following is closer to what you need:
UPDATED: Matching the original a bit more.