The user entered valuecan be either a string or an integer.
QAbstractTableModel setData()the method always gets this valueasQtCore.QVariant
Question
How to implement if/elif/elseinternally setData()to distinguish whether the resulting QVariantstring or integer? (therefore, the correct conversion method is used QVariant(such as .toString () or toInt ())
Ps Interestingly, trying to convert QVarianttoInt () results in a tuple, for example: (0, False)or(123, True)
source
share