how to implement for / foreach iteration ?
-
I am trying to learn how to use for / foreach .
Obviously I am not doing it correctly -
iterating thru QBluetoothLocalDevice.
I do not understand the "no index initialization " .foreach(localDevice)
{
text = localDevice->allDevices().at(0).address().toString();
CD->ui->list->addItem(text);
}QBluetoothLocalDevice *localDevice;
I would prefer a code for "foreach" first, maybe I can figure out the "for" later.
-
The old-style Qt-way (pre c++11) - see https://www.kdab.com/goodbye-q_foreach/ - don't use it.
For c++11 and later: https://en.cppreference.com/w/cpp/language/range-for (see examples)