Written by marcelpetrick
on September 18, 2018
Task is to connect from one signal with one parameter to a slot with zero parameters. With the “old” Qt4-way of connect it works like this
1 |
connect(object1, SIGNAL(signal(int param)), object2, SLOT(slot())) |
But what if I want to use the type-safe Qt5-connects?
The documentation just mentions the cases with:
* connect to default parameters in slot
* and (for example) using the above-mentioned way of the string-based connect.
My idea was to use a lambda to fix this:
1 |
connect(object1, &Object1::signal, [this](int) { slot(); } ); |
But it turned out in in this thread that
1 |
connect(&object1, &ClassObject1::signal, &object2, &ClassObject2::slot); |
is possible! 🙂