Reputation: 1816
As a sample, i have a function
void MyClass::foo( int i, int j ){ cout << i+j; }
and i wish that one signal execute a slot on some function of the class
connect( Object, SIGNAL( mysignal() ), SLOT( this->foo(1,2) ) );
With one argument its work, but show errors with 2 or more arguments on slot.
Upvotes: 1
Views: 3143
Reputation: 9037
Note that in Qt5 you can use the new signal/slot syntax and write this:
connect( pointerToObjectEmittingTheSignal, &MyClass::my_signal,
this, &MyOtherClass::my_slot);
the advantage being that if you make a mistake you'll get a compile-time error instead of a runtime error.
Upvotes: 3
Reputation: 5978
QT has excellent documentation on signals and slots http://qt-project.org/doc/qt-5/signalsandslots.html, make sure you understand the syntax. In your case it will be something like
connect( pointerToObjectEmittingTheSignal, SIGNAL(my_signal(int, int) ),
this, SLOT(my_slot(int, int));
In addition, your signal declaration should take two arguments of type int
and int
signals:
void my_signal(int, int);
Upvotes: 4