I have this
Struct values[] = {
{ a, b },
{ c, d }
};
And I just want to create a QList out of it
QList<Struct> ql(values + 0, values + 2);
But for some reason, QList has no suitable constructor and seemingly no suitable insert function. How does this work? I’m on Qt4.6.
One solution would be to first create an
std::listand then convert that into aQList:However, that would incurs two copies of the array content instead of just one.
The other solution is to use
std::copyalong with aback_inserter:If you use an array just to have an easy way to initialize the
QList, you could perhaps use the insertion operator instead (assumingStructdefines the proper constructor):