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. engine.rootContext()->setContextProperty change Instance
Forum Updated to NodeBB v4.3 + New Features

engine.rootContext()->setContextProperty change Instance

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 2 Posters 210 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.
  • neemeN Offline
    neemeN Offline
    neeme
    wrote on last edited by
    #1
    
    class Cust { };
    
    Cust *c1 = new Cust();
    Cust *c2 = new Cust();
    Cust *c3 = new Cust();
    
    engine.rootContext()->setContextProperty("cust",  c1);
    

    I have a Cust.qml file.
    How can i make cust -> c2 or cust -> c3 in Cust.qml ?

    Thank you!

    B 1 Reply Last reply
    0
    • neemeN neeme
      
      class Cust { };
      
      Cust *c1 = new Cust();
      Cust *c2 = new Cust();
      Cust *c3 = new Cust();
      
      engine.rootContext()->setContextProperty("cust",  c1);
      

      I have a Cust.qml file.
      How can i make cust -> c2 or cust -> c3 in Cust.qml ?

      Thank you!

      B Offline
      B Offline
      Bob64
      wrote on last edited by
      #2

      @neeme You need a new class that presents the same interface as Cust but which is implemented by delegating to the active instance of Cust. In addition, you need a means of selecting the active instance. It is not clear whether you want to control this from QML. If so, then simply add a suitable method to your new class.

      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