Qt Qvariant Example
#include "QVariant"
#include "QDebug"
 
using namespace std;
int main(int argc, char *argv[])
{
    QDataStream out(...);
    QVariant v(123);
    int x = v.toInt();
    qDebug() << "QVariant v is " << v;
    qDebug() << "v converted to int is " << x;
 
    v = QVariant("hello");      // The variant now contains a QString
    qDebug() << "QVariant v is " << v;
    qDebug() << "v converted to int is " << x;
 
}
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Share Alike 2.5 License.