I am trying to write a code snippet which would take a QList of QVariants and would populate the list using ListView.
Use cases with types QString, int, bool, double etc. are successful. However, when I am trying to pass char data type as list elements, it is being treated as integer i.e ASCII value is being taken.
Is there any way to make QVariant treat char as char?
Note: I am using Qt5.6.0. I have tried to probe the type by using QVariant::type() expecting it to return QVariant::Char so that I convert it to string and use it. But, QVariant::type() returned QVariant::Int.
int main()
{
QVariant charVar = 'A';
qDebug()<< charVar<< "\n";
return 0;
}
Actual result:
QVariant(int, 65)
Expectation:
QVariant(char, 'A')
int
and notchar
. In C++ simple char literals like'a'
should bechar
but multicharacter-literals like'abcd'
are stillint
– PeterT