Qvariant to int

if myVariant.canConvert(QMetaType.Int):
    value = myVariant.toInt()
elif myVariant.canConvert(QMetaType.QString)
    value = myVariant.toString()
Disturbed Dunlin