Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Define variable type on runtime

Define variable type on runtime

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 813 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    metRo_
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved