Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Containers
Qt 6.11 is out! See what's new in the release blog

Containers

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 2.2k 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.
  • D Offline
    D Offline
    Dmon
    wrote on last edited by
    #1

    What is the best container class to use for storing 3 instances of QLists? 3 derived classes from a base class that is implemented with the singleton design pattern, each creating a QList.

    1 Reply Last reply
    0
    • Chris KawaC Online
      Chris KawaC Online
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      QList [3], std::tuple, QList, QVector...
      Basically anything with constant access time. For 3 items it doesn't really matter unless you have some more specific requirements like memory constraint or binary layout etc.

      1 Reply Last reply
      0
      • D Offline
        D Offline
        Dmon
        wrote on last edited by
        #3

        So you are saying I should store the QLists within a QList(3)? And you would access them by referring to the number? 1,2,3 or 0,1,2?

        1 Reply Last reply
        0
        • Chris KawaC Online
          Chris KawaC Online
          Chris Kawa
          Lifetime Qt Champion
          wrote on last edited by
          #4

          It's a plain C++ array. Like in most other places in C++ indices are 0-based
          An example:
          @
          QList<QString> data[3]; //3 lists of strings
          data[0] << "foo" << "bar"; //add "foo" and "bar" to first list
          qDebug() << data[0][0]; //print first element of first list
          @

          1 Reply Last reply
          0
          • D Offline
            D Offline
            Dmon
            wrote on last edited by
            #5

            great thanks for the help.

            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