众所周知,Q的Variant类能够保存很多Qt中值,这里不是要分享怎样保存值,是想记录一下这种使用方式:
Variant::type()返回存储在Variant变量中的值的类型。
QVariant test1(1),test2(0.5),test3("hello Q");
qDebug()<<test1.type() << test2.type() << test3.type();
if(test1.type() == QVariant::Int)
qDebug()<<"奥利给";
打印结果:
QVariant::int QVariant::double QVariant::QString
奥利给