question in signals and slots
Solved
General and Desktop
-
Hi all
As I know , a value coulde be changed in other function like:void add(int &a) { a++; } int main() { int A = 0; add(&A); //then A will be 1; }
Now when I send a value by quote( & ), then change it in the slot:
class calculate:public QObject { Q_OBJECT public: calculate(); signals: void add(int &); public slots: void on_add(int &number); }; void calculate::on_add(int &a) { a++; } calculate::calculate() { int A = 0; connect(this, SIGNAL(add(int &)), this , SLOT(on_add(int &))); emit add(&A); //then A will be 1; }
Is that right?
Best regards.
Mihan -
Since signals and slots can be asynchronous you can't pass a non-const reference to a slot.