I have a function, which parses the file and fills a QMap<QString, int> with entries and returns a QVariant with value of that map:
QVariant FileParser::parseFile(QString filePath)
{
QMap<QString, int> toReturn;
... (parse the file and fill the map)
return QVariant::fromValue(toReturn);
}
When i check the contents of the map after calling it, i see an empty map:
QMap<QString, QVariant> words = FileParser().parseFile(QCoreApplication::applicationDirPath() + "/Input.txt").toMap();
qDebug()<<words; //Gives QMap()
This function works fine if i return QMap<QString, int>, but wrapping it in QVariant gives an empty map. Why might that be?