3
votes

I can't find a way to convert my QList<T> to a QVariant.

There's a constructor QVariant(const QList<QVariant> &val), but no constructor for QList<T> , is it possible to convert directly a QList<T> ?

1
Assume that your T typename is included in QVariant union types (otherwise you cannot). why you don't convert every T object in QVariant, put all this converted in QList<QVariant> and finally convert it to QVariant ?Mohamed Hamzaoui
@requinham I was hoping there was something more simple ...Evans Belloeil

1 Answers

4
votes

Example

QList<int> ints{1,2,3};
QVariant var = QVariant::fromValue<QList<int>>(ints);