Need more help with implementing for(each)
-
I am still lost with how to define the "for" variable. I understand the container, but unsure about the variable.
In this case my container is "RemoteDevicesList" and I want to retrieve humanly readable items from it - address and name .Can I find "common description" as a variable from the doc?

I tried using debug for such purpose, but was not successful finding the name for the "level". . (Does *d_otr has a "name" ?)

-
I am still lost with how to define the "for" variable. I understand the container, but unsure about the variable.
In this case my container is "RemoteDevicesList" and I want to retrieve humanly readable items from it - address and name .Can I find "common description" as a variable from the doc?

I tried using debug for such purpose, but was not successful finding the name for the "level". . (Does *d_otr has a "name" ?)

@AnneRanch I think I got part of it
RemoteDevicesList.append(info);
QList<QBluetoothDeviceInfo> RemoteDevicesList_TEMP = localDevice.allDevices(); RemoteDevicesList_TEMP.append(info); QList<QBluetoothHostInfo> BT_HostInfo = localDevice.allDevices(); for (auto localDevice : RemoteDevicesList_TEMP) {however I am getting this weird error - I do not get where is the
QBluetoothHostInfo
coming from
my list is
QBluetoothDeviceInfo
/media/nov25-1/AAA_OS_RAID/RECOVERY_BACKUP_FEB17_1/RECOVERY/BLUETOOTH/SOURCE/CCC_SOURCE/terminal_SERIAL_BLUETOOTH_VER_1/terminal_SERIAL_BLUETOOTH/terminal_BLUETOOTH/mainwindow_BT_Terminal.cpp:1493: error: no viable conversion from 'QList<QBluetoothHostInfo>' to 'QList<QBluetoothDeviceInfo>' mainwindow_BT_Terminal.cpp:1493:33: error: no viable conversion from 'QList<QBluetoothHostInfo>' to 'QList<QBluetoothDeviceInfo>' QList<QBluetoothDeviceInfo> RemoteDevicesList_TEMP = localDevice.allDevices(); ^ ~~~~~~~~~~~~~~~~~~~~~~~~ /home/nov25-1/Qt/Nov26/5.15.2/gcc_64/include/QtCore/qlist.h:161:5: note: candidate constructor not viable: no known conversion from 'QList<QBluetoothHostInfo>' to 'const QList<QBluetoothDeviceInfo> &' for 1st argument QList(const QList<T> &l); ^ /home/nov25-1/Qt/Nov26/5.15.2/gcc_64/include/QtCore/qlist.h:164:12: note: candidate constructor not viable: no known conversion from 'QList<QBluetoothHostInfo>' to 'QList<QBluetoothDeviceInfo> &&' for 1st argument inline QList(QList<T> &&other) noexcept ^ /home/nov25-1/Qt/Nov26/5.15.2/gcc_64/include/QtCore/qlist.h:169:12: note: candidate constructor not viable: no known conversion from 'QList<QBluetoothHostInfo>' to 'std::initializer_list<QBluetoothDeviceInfo>' for 1st argument inline QList(std::initializer_list<T> args) ^ -
@AnneRanch I think I got part of it
RemoteDevicesList.append(info);
QList<QBluetoothDeviceInfo> RemoteDevicesList_TEMP = localDevice.allDevices(); RemoteDevicesList_TEMP.append(info); QList<QBluetoothHostInfo> BT_HostInfo = localDevice.allDevices(); for (auto localDevice : RemoteDevicesList_TEMP) {however I am getting this weird error - I do not get where is the
QBluetoothHostInfo
coming from
my list is
QBluetoothDeviceInfo
/media/nov25-1/AAA_OS_RAID/RECOVERY_BACKUP_FEB17_1/RECOVERY/BLUETOOTH/SOURCE/CCC_SOURCE/terminal_SERIAL_BLUETOOTH_VER_1/terminal_SERIAL_BLUETOOTH/terminal_BLUETOOTH/mainwindow_BT_Terminal.cpp:1493: error: no viable conversion from 'QList<QBluetoothHostInfo>' to 'QList<QBluetoothDeviceInfo>' mainwindow_BT_Terminal.cpp:1493:33: error: no viable conversion from 'QList<QBluetoothHostInfo>' to 'QList<QBluetoothDeviceInfo>' QList<QBluetoothDeviceInfo> RemoteDevicesList_TEMP = localDevice.allDevices(); ^ ~~~~~~~~~~~~~~~~~~~~~~~~ /home/nov25-1/Qt/Nov26/5.15.2/gcc_64/include/QtCore/qlist.h:161:5: note: candidate constructor not viable: no known conversion from 'QList<QBluetoothHostInfo>' to 'const QList<QBluetoothDeviceInfo> &' for 1st argument QList(const QList<T> &l); ^ /home/nov25-1/Qt/Nov26/5.15.2/gcc_64/include/QtCore/qlist.h:164:12: note: candidate constructor not viable: no known conversion from 'QList<QBluetoothHostInfo>' to 'QList<QBluetoothDeviceInfo> &&' for 1st argument inline QList(QList<T> &&other) noexcept ^ /home/nov25-1/Qt/Nov26/5.15.2/gcc_64/include/QtCore/qlist.h:169:12: note: candidate constructor not viable: no known conversion from 'QList<QBluetoothHostInfo>' to 'std::initializer_list<QBluetoothDeviceInfo>' for 1st argument inline QList(std::initializer_list<T> args) ^When localDevice.allDevices() returns a list of QBluetoothDeviceInfo you can't store the results in a list of QBluetoothHostInfo.
-
When localDevice.allDevices() returns a list of QBluetoothDeviceInfo you can't store the results in a list of QBluetoothHostInfo.
@Christian-Ehrlicher I am not. Sorry, but I included code for working for(each) , There are TWO different QList in my snippet. The first one fails as error posted.
-
@Christian-Ehrlicher I am not. Sorry, but I included code for working for(each) , There are TWO different QList in my snippet. The first one fails as error posted.
@AnneRanch said in Need more help with implementing for(each):
There are TWO different QList in my snippet. The first one fails as error posted.
correct
no viable conversion from 'QList<QBluetoothHostInfo>' to 'QList<QBluetoothDeviceInfo>'
QList<QBluetoothDeviceInfo> RemoteDevicesList_TEMP = localDevice.allDevices();This warning does not come from the for() but from the assignment and I wrote what's wrong (even I only said what the compiler error already told you).