First argument to a method is the instance itself which is passed implicitly and generally named as self
. In your version, something
becomes the instance, not the passed parameter. Your method should look like:
def foo(self, something):
print something
As a side note, normally you would get an error while passing a parameter to a method that doesn't accept any. Like:
class Foo(object):
def bar(something):
print something
f = Foo()
f.bar(1)
#Traceback (most recent call last):
# File "<stdin>", line 1, in <module>
#TypeError: bar() takes exactly 1 argument (2 given)
But in Qt, you can connect a signal to a slot that accepts less parameters. Qt will call the slot without that parameter. So, although the clicked
signal passes the QModelIndex
, you can still connect this signal to a method that doesn't accept a parameter (like your foo
). In result, you'll get this silent 'bug'.