Man*_*olo 1 python qt pyqt args slots
我有一个奇怪的问题.这是我的代码:
def method1(self, arg1, delay=True):
"""This is a method class"""
def recall(arg1):
self.method1(arg1, delay=False)
return
if delay:
print "A: ", arg1, type(arg1)
QtCore.QTimer.singleShot(1, self, QtCore.SLOT(recall(int)), arg1)
return
print "B: ", arg1, type(arg1)
Run Code Online (Sandbox Code Playgroud)
所以我在控制台中得到这个:
A: 0 <type 'int'>
B: <type 'int'> <type 'type'>
Run Code Online (Sandbox Code Playgroud)
在"B"中你应该得到与"A"相同的东西.谁知道什么是错的?如何获取arg1值而不是其类型?这没有任何意义......
PS:我正在尝试这样的事情:http://lists.trolltech.com/qt-interest/2004-08/thread00659-0.html
传递给SLOT函数的参数必须是一个字符串,其类型为参数,而不是直接调用,因此您无法将带参数的插槽连接到没有任何参数的信号.
您可以使用lambda函数:
QtCore.QTimer.singleShot(1, lambda : self.recall(arg1))
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4957 次 |
| 最近记录: |