# Is it possible to make a QList of tuples?

• Something like

``````QList<std::tuple<int,int>> mapCoordinatesList = {(10,10), (10,30), (40,70), (120,80), (190,60), (220,30), (220,0)};

``````

That can be accessed with

``````xVal = mapCoordinatesList
``````

• Why not use QVector<QPoint> instead and what does not work in your example?

• Why not use QVector<QPoint> instead and what does not work in your example?

My guess is, the initalizer list does not auto convert to std::tuple? Because this one works

``````QList<std::tuple<int,int>> mapCoordinatesList = {std::tuple<int,int>(10,10), std::tuple<int,int>(10,30), std::tuple<int,int>(40,70), std::tuple<int,int>(120,80), std::tuple<int,int>(190,60), std::tuple<int,int>(220,30), std::tuple<int,int>(220,0)};
``````

• @abanksdev
Something like this should also work:

``````struct MyTuple {
int x;
int y;
};
QList<MyTuple> mapCoordinatesList = {
{10,10}, {10,30}, {40,70}, {120,80}, ...
};
``````

(untested)

• My guess is, the initalizer list does not auto convert to std::tuple?

Correct, there are also a lot of answers in the net why it does not work. :)

• @Christian-Ehrlicher
I get the following error

``````/Users/banks.audrey/altitudeStatusFrame/main.cpp:6: error: no matching constructor for initialization of 'QList<std::tuple<int, int> >'
QList<std::tuple<int,int>> mapCoordinatesList = {(10,10), (10,30), (40,70), (120,80), (190,60), (220,30), (220,0)};
^                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
``````

Let me try what @J-Hilk suggested

but also QVectory<QPoint> would work, but im getting the following error:

``````/Users/banks.audrey/altitudeStatusFrame/main.cpp:11: error: implicit instantiation of undefined template 'QVector<QPoint>'
QVector<QPoint> statusFrameCoordinatesList(7);
^
``````

• Hi,

Use: `QList<std::tuple<int,int>> mapCoordinatesList = {{10,10}, {10,30}, {40,70}, {120,80}, {190,60}, {220,30}, {220,0}};`

As for your second error, I can't reproduce it.

What compiler are you using ?

• I used @raven-worx's method and got it working, thanks!