C++ (Qt)SomeClass { SomeClass(int p1, const QString &p2) : _param1(p1), _param2(p2) {} inline int param1() const { return _param1; } inline QString param2() const { return _param2; }private: int _param1; QString _param2;};Q_DECLARE_METATYPE(SomeClass)
C++ (Qt) QSqlQuery query; query.prepare("INSERT INTO table VALUES(?)"); query.addBindValue(QVariant::fromValue(SomeClass(1, "2")); query.exec();
C++ (Qt)SomeDbManager::addRecord(QVariantList list) { QSqlQuery query; query.prepare(QString("INSERT INTO table VALUES(%1)").arg(prepareValues(lilst.size()); foreach (QVariant value, list) query.addBindValue(value); return query.exec();}
C++ (Qt) if (value.type() == someClassType) addBindValue(value.value<SomeClass>().toString()); else addBindValue(value);
C++ (Qt)SomeDbManager::record(int recId) { QSqlQuery query; QVariantList list; ... for (int i = 0; i < rowSize; ++i) { list << query.value(i); } return list;}
C++ (Qt)list.at(i).canConvert<SomeClass>(); // false;