if myVariant.type() == QVariant.Int:
value = myVariant.toInt()
elif myVariant.type() == QVariant.QString:
value = myVariant.toString()
if myVariant.canConvert(QMetaType.Int):
value = myVariant.toInt()
elif myVariant.canConvert(QMetaType.QString)
value = myVariant.toString()