Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Conditional rendering of simulation vs production
Qt 6.11 is out! See what's new in the release blog

Conditional rendering of simulation vs production

Scheduled Pinned Locked Moved Solved QML and Qt Quick
2 Posts 2 Posters 390 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.
  • R Offline
    R Offline
    Redman
    wrote on last edited by
    #1

    Hello,

    I have an application that communicates with some hardware. I do not always have the hardware at hand, so I wrote class hardwaredriver aswell as class hardwaredriversimulation. I have a config that is read upon application start, so I know if its a simulation or production run.

    How can I make sure the correct QML Object is created without doing something like this in QML

    if (profile == simulation)
       hardwaredriversimu{}
    else
       hardwaredriver{}
    

    Doesnt look too clean to me. Anyone got any ideas?

    sierdzioS 1 Reply Last reply
    0
    • R Redman

      Hello,

      I have an application that communicates with some hardware. I do not always have the hardware at hand, so I wrote class hardwaredriver aswell as class hardwaredriversimulation. I have a config that is read upon application start, so I know if its a simulation or production run.

      How can I make sure the correct QML Object is created without doing something like this in QML

      if (profile == simulation)
         hardwaredriversimu{}
      else
         hardwaredriver{}
      

      Doesnt look too clean to me. Anyone got any ideas?

      sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      @Redman you can use file selectors for that. Example: https://doc.qt.io/qt-6/qtquickcontrols-fileselectors.html

      (Z(:^

      1 Reply Last reply
      2
      • R Redman has marked this topic as solved on

      • Login

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