Nominate our 2022 Qt Champions!

Define variable type on runtime

  • Hi,
    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?

    Thank you

  • Moderators

    Take a look at "QVariant": It's a class that can store a value of different types and even provides conversions between them.

Log in to reply