Important: Please read the Qt Code of Conduct -

[SOLVED]Multidimensional array

  • Hi guys,

    I'm trying to use a multidimensional array:

    QList<QList<QVariant> > info;
    //Append QList<QVariant> works...>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?


  • 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!

  • Moderators

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

  • It works!

    Thank you Krysztorf Kawa!

Log in to reply