Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. Need more help with implementing for(each)
Qt 6.11 is out! See what's new in the release blog

Need more help with implementing for(each)

Scheduled Pinned Locked Moved Unsolved C++ Gurus
5 Posts 2 Posters 665 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Anonymous_Banned275
    wrote on last edited by
    #1

    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?

    b010dd41-28f2-432e-b513-1d377c9f97b8-image.png

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

    a838a952-9569-49de-bcd2-e8a7bd053523-image.png

    A 1 Reply Last reply
    0
    • A Anonymous_Banned275

      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?

      b010dd41-28f2-432e-b513-1d377c9f97b8-image.png

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

      a838a952-9569-49de-bcd2-e8a7bd053523-image.png

      A Offline
      A Offline
      Anonymous_Banned275
      wrote on last edited by
      #2

      @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)
                 ^
      
      Christian EhrlicherC 1 Reply Last reply
      0
      • A Anonymous_Banned275

        @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)
                   ^
        
        Christian EhrlicherC Online
        Christian EhrlicherC Online
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on last edited by
        #3

        When localDevice.allDevices() returns a list of QBluetoothDeviceInfo you can't store the results in a list of QBluetoothHostInfo.

        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
        Visit the Qt Academy at https://academy.qt.io/catalog

        A 1 Reply Last reply
        1
        • Christian EhrlicherC Christian Ehrlicher

          When localDevice.allDevices() returns a list of QBluetoothDeviceInfo you can't store the results in a list of QBluetoothHostInfo.

          A Offline
          A Offline
          Anonymous_Banned275
          wrote on last edited by
          #4

          @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 EhrlicherC 1 Reply Last reply
          0
          • A Anonymous_Banned275

            @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 EhrlicherC Online
            Christian EhrlicherC Online
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @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).

            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
            Visit the Qt Academy at https://academy.qt.io/catalog

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved