I am trying to append values to a QList
inside another QList
but it doesn't seem to work?
Here is a MCVE of my problem where I try to append int values:
#include <QList>
#include <QDebug>
int main(int argc, char *argv[]) {
QList<QList<int>> my_list;
int result;
for (int i = 0; i < 2; ++i) {
for (int j = 0; j < 4; ++j) {
result = i * j;
my_list.value(i).push_back(result);
qDebug() << my_list.size() << "," << my_list.value(i).size() << " : " << my_list.value(i).value(j);
}
}
return 0;
}
This yields:
Starting C:\Users\ ... \build\release\name_of_the_app.exe...
0 , 0 : 0
0 , 0 : 0
0 , 0 : 0
0 , 0 : 0
0 , 0 : 0
0 , 0 : 0
0 , 0 : 0
0 , 0 : 0
C:\Users\ ... \build\release\name_of_the_app.exe exited with code 0
Can anyone please tell me what I'm doing wrong?