3

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> ?

Evans Belloeil
  • 2,413
  • 7
  • 43
  • 76
  • 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 and finally convert it to QVariant ? – Mohamed Hamzaoui Jun 08 '17 at 13:00
  • @requinham I was hoping there was something more simple ... – Evans Belloeil Jun 08 '17 at 13:03

1 Answers1

4

Example

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