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. Passing pointer to custom QML Type?
Forum Updated to NodeBB v4.3 + New Features

Passing pointer to custom QML Type?

Scheduled Pinned Locked Moved QML and Qt Quick
qt quick
4 Posts 3 Posters 1.2k Views 2 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.
  • David.GD Offline
    David.GD Offline
    David.G
    wrote on last edited by
    #1

    I have a "service" class that supplies whatever object the information they need. I'm not sure if I'm thinking this right, but the main idea is to have my custom QML type, let's call it Message to obtain the pointer before I use qmlRegisterType so it has said pointer and I don't have to write:

    Message {
    id: something
    data: serviceProvider (service class, of course)
    messageId: <int>
    } 
    
    

    Over and over again.

    That said I just couldn't see any way of doing this, although the other way I found would be injecting the service into the rootContext in which I'm not exactly fond of the idea but if that's the only way then I guess I shall abide.

    Any thoughts, ideas?

    1 Reply Last reply
    0
    • benlauB Offline
      benlauB Offline
      benlau
      Qt Champions 2016
      wrote on last edited by
      #2

      Not quite understand your question, but seems that what you are looking for should be Singleton object.

      QQmlEngine Class | Qt QML 5.5

      David.GD 1 Reply Last reply
      0
      • J Offline
        J Offline
        jduran_gm
        wrote on last edited by
        #3

        This could be an strating point:

        http://doc.qt.io/qt-5/qtqml-cppintegration-topic.html

        1 Reply Last reply
        0
        • benlauB benlau

          Not quite understand your question, but seems that what you are looking for should be Singleton object.

          QQmlEngine Class | Qt QML 5.5

          David.GD Offline
          David.GD Offline
          David.G
          wrote on last edited by
          #4

          @benlau That's pretty close yea, I'll take a look today.

          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