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.
#include <QCoreApplication>
#include <QVariant>
#include <QList>
#include <iostream>
Q_DECLARE_METATYPE(QList<double>)
int main(int argc, char *argv[])
{
qRegisterMetaType<QList<double> >("QList<double>");
QList<double> x1;
for(int i=0; i<30; i++)
x1.append((double)i);
x2.fromValue<QList<double> >(x1);
QList<double> x3 = x2.value<QList<double> >();
for(int i=0; i<x3.size(); i++)
std::cout << x3[i] << "\n";
std::cout << "***";
return a.exec();
}
#include <QCoreApplication>
#include <QVariant>
#include <QList>
#include <iostream>
Q_DECLARE_METATYPE(QList<double>)
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
qRegisterMetaType<QList<double> >("QList<double>");
QList<double> x1;
for(int i=0; i<30; i++)
x1.append((double)i);
QVariant x2;
x2.fromValue<QList<double> >(x1);
QList<double> x3 = x2.value<QList<double> >();
for(int i=0; i<x3.size(); i++)
std::cout << x3[i] << "\n";
std::cout << "***";
return a.exec();
}
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!
Bookmarks