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. Registering created object in qmlRegisterType<T>. How?

Registering created object in qmlRegisterType<T>. How?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
3 Posts 2 Posters 468 Views
  • 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.
  • B Offline
    B Offline
    bogong
    wrote on last edited by bogong
    #1

    Hello all!

    Got a question about registering created object like QML component after few actions:

    QMLCustomComponent *oQMLCustomComponent = new QMLCustomComponent();
    oQMLCustomComponent->doMethod1();
    oQMLCustomComponent->doMethod2();
    oQMLCustomComponent->doMethod3();
    
    qmlRegisterType<oQMLCustomComponent>("Custom.Component",1,0,"CustomComponent");
    

    I need to register created object after few actions in QML Engine. Is it possible to do it? If yes how?

    1 Reply Last reply
    0
    • IntruderExcluderI Offline
      IntruderExcluderI Offline
      IntruderExcluder
      wrote on last edited by IntruderExcluder
      #2

      Registered that way and created at QML component CustomComponent will be just another istance of your QMLCustomComponent class. If you want to use exactly oQMLCustomComponent you must set it as context property. Also you can read about registering singletons via C++.

      B 1 Reply Last reply
      0
      • IntruderExcluderI IntruderExcluder

        Registered that way and created at QML component CustomComponent will be just another istance of your QMLCustomComponent class. If you want to use exactly oQMLCustomComponent you must set it as context property. Also you can read about registering singletons via C++.

        B Offline
        B Offline
        bogong
        wrote on last edited by
        #3

        @intruderexcluder Here the thing - I need component itself but not context of component. The next idea that I got about it to use OOP Builder template that will be checking parameters automatically and run methods at time of construction of the object.

        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