单发:带有参数的SLOT [英] Singleshot: SLOT with arguments

查看:504
本文介绍了单发:带有参数的SLOT的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个奇怪的问题.这是我的代码:

I have a strange problem. Here is my code:

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)

所以我可以在控制台中找到它:

So I get this in console:

A:  0 <type 'int'>
B:  <type 'int'> <type 'type'>

在"B"中,您应获得与在"A"中相同的结果.有人知道怎么了吗?我如何获得arg1值 而不是它的类型?这没有任何意义...

In "B" you should get the same than in "A". Anyone knows what's wrong? How can I get the arg1 value instead of its type? This is not making any sense...

PS:我正在尝试这样的事情: http://lists.trolltech.com/qt-interest/2004-08/thread00659-0.html

PS: I'm trying something like this: http://lists.trolltech.com/qt-interest/2004-08/thread00659-0.html

推荐答案

调用时看起来像这样:

QtCore.QTimer.singleShot(1, self, QtCore.SLOT(recall(int)), arg1)

您是要打电话给它吗?

QtCore.QTimer.singleShot(1, self, QtCore.SLOT(recall(arg1)), arg1)

您将int作为recall的第一个参数传递,它直接将其传递给method1. int是类型对象(整数类型).

you are passing int as the first argument of recall, which passes it directly to method1. int is a type object (the type of integers).

这篇关于单发:带有参数的SLOT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆