Hi!

I'm trying to store my QList to QVariant and than convert it back to QList.

This is minimal example of what I'm trying to do. Real application would be more complex, but on same basis.

Qt Code:
  1. #include <QCoreApplication>
  2. #include <QVariant>
  3. #include <QList>
  4. #include <iostream>
  5.  
  6. Q_DECLARE_METATYPE(QList<double>)
  7.  
  8. int main(int argc, char *argv[])
  9. {
  10. QCoreApplication a(argc, argv);
  11.  
  12. qRegisterMetaType<QList<double> >("QList<double>");
  13.  
  14. QList<double> x1;
  15. for(int i=0; i<30; i++)
  16. x1.append((double)i);
  17.  
  18. x2.fromValue<QList<double> >(x1);
  19.  
  20. QList<double> x3 = x2.value<QList<double> >();
  21. for(int i=0; i<x3.size(); i++)
  22. std::cout << x3[i] << "\n";
  23.  
  24. std::cout << "***";
  25.  
  26. return a.exec();
  27. }
To copy to clipboard, switch view to plain text mode 

Above code compiles without any warnings but running the code does not produce expected results.

Can somebody tell me what am I doing wrong?
Thanx!