Question

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'>

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: I'm trying something like this: http://lists.trolltech.com/qt-interest/2004-08/thread00659-0.html

Was it helpful?

Solution

It looks like when you are calling this:

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

are you meaning to call this instead?

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

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).

OTHER TIPS

The parameter passed to the SLOT function must be a string with types as parameters, not a direct call, so you can't connect a slot with parameters to a signal without any parameter.

You can use a lambda function instead:

QtCore.QTimer.singleShot(1, lambda : self.recall(arg1))
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top