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
Forum Updated to NodeBB v4.3 + New Features

Conditional rendering of simulation vs production

Scheduled Pinned Locked Moved Solved QML and Qt Quick
2 Posts 2 Posters 222 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 4 Mar 2024, 08:05 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?

    S 1 Reply Last reply 4 Mar 2024, 09:11
    0
    • R Redman
      4 Mar 2024, 08:05

      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?

      S Offline
      S Offline
      sierdzio
      Moderators
      wrote on 4 Mar 2024, 09:11 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 4 Mar 2024, 09:43

      1/2

      4 Mar 2024, 08:05

      • Login

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