Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Qt Academy Launch in California!

    Pointers in QML?

    QML and Qt Quick
    2
    2
    3275
    Loading More Posts
    • 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.
    • E
      excalibur1491 last edited by

      Hi,
      I have a question about objects in QML, I couldn't find any information on the internet.
      Lets say I have a class "A" that inherits of QDeclarativeItem.
      I can insatnciate perfectlly my class A and I can work with it on QML with no problem at al.
      But I have a method (in C++) of another class that takes a A** as an argument.
      How can I pass a pointer to a QML Item to this method? If I just put "&m" (m is the id of my instance of A), it does not compile.
      Any clue?

      Thank you!

      1 Reply Last reply Reply Quote 0
      • sierdzio
        sierdzio Moderators last edited by

        QML works using meta-object information only. You can pass a QObject pointer between methods and then use qobject_cast<>() to get an object of your A class (or, if you prefer, you can simply use the meta information to interact with the QObject).

        (Z(:^

        1 Reply Last reply Reply Quote 0
        • First post
          Last post