sending variables dynamically using signals and slots
Solved
General and Desktop
-
@Lasith Well, emit a signal, pass the current value to it as parameter. Connect the signal to the slot.
// somewhere in your code connect(this, SIGNAL(mySignal(int)), otherObject, SLOT(mySlot(int))); for (int i = 0; i < 10; ++i) { emit mySignal(i); } // In the other class void MyObject::mySlot(const int value) { // Do something }
Did you read http://doc.qt.io/qt-5.9/signalsandslots.html ?
Actually you should think about the need of signals and slots in this particular case - maybe it will be much easier and faster to directly call a method from the other class instead of emitting a signal? Signals/slots are useful if you want to have loose coupling, so the sender does not need to know anything about receiver.