1

QTabWidget has signal currentChanged(). And it returns index of current tab.
But how can I get this parameter in such expression:

tabs.currentChanged.connect(lambda: foo());

def foo(index):
    ...

Where should I look for this parameter that was just returned?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Qiao
  • 16,565
  • 29
  • 90
  • 117
  • An answer of mine to a previous question of yours would be helpful: [Previous Question](http://stackoverflow.com/questions/6159021/lambda-i-i-fooi-in-for-loop-not-working/6162445#6162445) – pedrotech May 29 '11 at 13:34

1 Answers1

3

Signals don't "return" anything. They can have parameters though, which is the case for currentIndex. If you want that argument passed to your function, you should try:

tabs.currentChanged.connect(lambda index: foo(index));
Mat
  • 202,337
  • 40
  • 393
  • 406
  • It works, thank you. Why you say that it is not returned? Signal returns (emit, pass, send) parameter to slot. Who else if not signal did it? – Qiao May 29 '11 at 09:52
  • 2
    A signal can pass/emit/send values to a slot. It does not return values to it. That's just vocabulary/terminology. – Mat May 29 '11 at 10:06
  • Is there any good reason to use the lambda here? Can't you just do `tabs.currentChanged.connect(foo)`? Maybe I'm missing something... – Whatang May 29 '11 at 16:28
  • @Whatang: I have no idea, I'm not really familiar with python. – Mat May 29 '11 at 16:37