Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Define variable type on runtime
metRo_ last edited by
I have to analyse an xml file that will tell me the name and the variables associated with a sensor. Per example, the xml tell that there is a temperature sensor and the data is saved on a float, then there is a door sensor and data is saved on a int and also I can have a sensor that gives me two values.
My first thought was to create a class where I'll save the name of the sensor and then a vector where I save the values but I don't know the variable type before read the xml file.
How can I do that?
Take a look at "QVariant":http://qt-project.org/doc/qt-5/qvariant.html. It's a class that can store a value of different types and even provides conversions between them.