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. how to implement for / foreach iteration ?
Forum Updated to NodeBB v4.3 + New Features

how to implement for / foreach iteration ?

Scheduled Pinned Locked Moved Unsolved C++ Gurus
2 Posts 2 Posters 429 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 Anonymous_Banned275
    #1

    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.

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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)

      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
      1

      • Login

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