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. [SOLVED]Multidimensional array
Forum Updated to NodeBB v4.3 + New Features

[SOLVED]Multidimensional array

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 6.3k 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.
  • R Offline
    R Offline
    ranger0
    wrote on last edited by
    #1

    Hi guys,

    I'm trying to use a multidimensional array:

    @
    QList<QList<QVariant> > info;
    //Append QList<QVariant> works...
    info.at(0).append(query->value(0));
    @

    When I try do append same data at info (line 3) I have the error: "error: passing 'const QList<QVariant>' as 'this' argument of 'void QList<T>::append(const T&) [with T = QVariant]' discards qualifiers"

    Does anyone has a clue of how to fix this?

    Thanks.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      MuldeR
      wrote on last edited by
      #2

      Seems like the method from which do execute the code (line 3) is inside a "const" method.

      Methods with "const" keyword can read member variables (such as info), but not modify them!

      My OpenSource software at: http://muldersoft.com/

      Qt v4.8.6 MSVC 2013, static/shared: http://goo.gl/BXqhrS

      Go visit the coop: http://youtu.be/Jay...

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

        at() returns const reference. Use operator [] instead to modify the list element (the append() modifies it).

        1 Reply Last reply
        0
        • R Offline
          R Offline
          ranger0
          wrote on last edited by
          #4

          It works!

          Thank you Krysztorf Kawa!

          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