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. Pointers in QML?
Qt 6.11 is out! See what's new in the release blog

Pointers in QML?

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 2 Posters 3.9k 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.
  • E Offline
    E Offline
    excalibur1491
    wrote on last edited by
    #1

    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
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      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
      0

      • Login

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