QVector various data format

I am wandering if I can use a multi dimensions QVector to store data with different format
Of course the QVector<QVector<QString> > is working but only for a same data format
( QString in this example)Is there a way to define several data format (one per dimension) within the same Qvector ?

Hi, and welcome to the Qt forum! How about using
QVariant
?

@Wieland
Thks for your help, that's really what I was looking for.
However I have another question regarding a QVector multi dimensions structure.For instance a structure declared like this:
QVector< QVector< QVector< QVariant > > > test_vector_3d;
QVector< QVector< QVariant > > test_vector_2d;
QVector< QVariant > test_vector_1d;QVariant qv1="item1";
QVariant qv2="item2";
QVariant qv3="item3";test_vector_1d.append(qv1);
test_vector_1d.append(qv2);test_vector_2d.append(test_vector_1d);
How can I append a third QVariant (qv3) to the test_vector_3d ?
Thks in advance

QVector< QVector< QVector< QVariant > > >
is a vector of vectors of vectors of variants ie a 3D "cube" of QVariants.
What's the expected result i.e. to which dimension do you want the value appended? Because there's no one answer to this question. In other words which of the 8 corners of the cube should expand?

In my example only test_vector _2d is filled with values eg: test_vector_2d [item2] [item1]
My question is about how to load a value [item3] for the 3rd dimension
test_vector_3d [??] [item2] [item1]It should be something like this:
test_vector_3d.append(test_vector_2d);but I can't figure out how to append the QVariant qv3 to this array

@jipe3001 said:
test_vector_3d [??] [item2] [item1]
item1 and item2 are not indices so that's not what you have in your example. What you have is:
test_vector_1d[0] == item1 test_vector_1d[1] == item2 test_vector_2d[0][0] == item1 test_vector_2d[0][1] == item2
So again, what's your desired result. Any of these?
test_vector_3d[0][0][0] == item3 test_vector_3d[0][0][1] == item3 test_vector_3d[0][1][0] == item3 test_vector_3d[1][0][0] == item3 test_vector_3d[0][1][1] == item3 test_vector_3d[1][1][0] == item3 test_vector_3d[1][0][1] == item3 test_vector_3d[1][1][1] == item3

You are right I did not mean item x was an index but the value in the cell, my mistake !
Here is a screen shot of a debug session, showing the 1d,2d, 3d vectors after being initialize with append as described in my previous msg.
v_records_1d <3 éléments> QVector<QVariant> [0] (int) 1 QVariant d struct QVariant::Private QVariant::Private data union QVariant::Private::Data union QVariant::Private::Data type 2 unsigned int is_shared 0 unsigned int is_null 0 unsigned int [1] (int) 9869 QVariant [2] (double) 16.140000000000001 QVariant v_records_2d <1 élément> QVector<QVector<QVariant>> [0] <3 éléments> QVector<QVariant> [0] (int) 1 QVariant [1] (int) 9869 QVariant [2] (double) 16.140000000000001 QVariant v_records_3d <1 élément> QVector<QVector<QVector<QVariant>>> [0] <1 élément> QVector<QVector<QVariant>> [0] <3 éléments> QVector<QVariant> [0] (int) 1 QVariant [1] (int) 9869 QVariant [2] (double) 16.140000000000001 QVariant
We can see that
test_vector_3d[0][0][0] = 1
test_vector_3d[0][0][1] = 9869
test_vector_3d[0][0][2] = 16.14My question is how can I enter values using append method for
test_vector_3d[0][1][0]
test_vector_3d[0][1][1]
test_vector_3d[0][1][2]and
test_vector_3d[1][1][0]
test_vector_3d[1][1][1]
test_vector_3d[1][1][2]

To put something in item indexed [1] there's gotta be item [0] first, so to get
test_vector_3d[0][1][0] test_vector_3d[0][1][1] test_vector_3d[0][1][2]
you'd do:
QVector<QVariant> test_vector_1d; test_vector_1d.append(1); test_vector_1d.append(9869); test_vector_1d.append(16.14); QVector<QVector<QVariant>> test_vector_2d; test_vector_2d.append(QVector<QVariant>()); //that's index [0] test_vector_2d.append(test_vector_1d); //that's index [1] QVector<QVector<QVector<QVariant>>> test_vector_3d; test_vector_3d.append(test_vector_2d);
Similarly, to get
test_vector_3d[1][1][0] test_vector_3d[1][1][1] test_vector_3d[1][1][2]
you'd do:
QVector<QVariant> test_vector_1d; test_vector_1d.append(1); test_vector_1d.append(9869); test_vector_1d.append(16.14); QVector<QVector<QVariant>> test_vector_2d; test_vector_2d.append(QVector<QVariant>()); //that's index [0] test_vector_2d.append(test_vector_1d); //that's index [1] QVector<QVector<QVector<QVariant>>> test_vector_3d; test_vector_3d.append(QVector<QVector<QVariant>>()); //that's index [0] test_vector_3d.append(test_vector_2d); //that's index [1]
