[solved] std::vector to QList?
-
hello
I would like to convert a std vector into a QList. Thing is, the type might vary, so I'd like to use a QList<QVariant> (the std vector might be int, double or string but I know this when I add the data).
I tried the following@QList<QVariant> tmp = QList<int>::fromVector( QVector<int>::fromStdVector(stdVectorInt)); @
But is fails as the int type doesn't match the qvariant type. Is ther enay way of doing this without having to loop trough the vector and add one item at a time? Thanks
Richard -
I don't think there's a way for this automatic conversion, because there is AFAIK no way to set
@QList<X> = QList<Y>@
because these are different datatypes and the compiler does not know how to convert them.
You could probably subclass QList to do that conversion, but I think this would require looping through the list - but on the other hand I think that's what is done anyway.