Results 1 to 4 of 4

Thread: Access instantiated objects from C++

  1. #1
    Join Date
    Dec 2010
    Posts
    6
    Thanked 2 Times in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Access instantiated objects from C++

    Hey,


    how can I access instantiated objects from C++?

    e.g.:

    I have a .qml file:


    Qt Code:
    1. MyItem {
    2. task: "doThis"
    3. // ...
    4. }
    5. MyItem {
    6. task: "doThat"
    7. // ...
    8. }
    9. // and further more
    To copy to clipboard, switch view to plain text mode 

    How can I now iterate through this file from a C++ application?
    I'd like to check the 'task' property from each item.


    thanks

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Access instantiated objects from C++

    Your items are likely to be available as context properties of the declarative context.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Dec 2010
    Posts
    6
    Thanked 2 Times in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Access instantiated objects from C++

    hey wysota,

    thanks for your answer, but could you explain that with a little example?

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Access instantiated objects from C++

    Take a look at QDeclarativeContext::contextProperty() and also read about making your C++ objects available for QML. What you want is using the same mechanism in the other direction.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Replies: 17
    Last Post: 11th April 2013, 10:35
  2. ActiveQt : requested control could not be instantiated
    By zirconius in forum Qt Programming
    Replies: 2
    Last Post: 9th April 2010, 14:27
  3. How to access an object inside a privateslot
    By graciano in forum Qt Programming
    Replies: 7
    Last Post: 21st January 2009, 19:09
  4. Access an object stored in the list.
    By cbarmpar in forum General Programming
    Replies: 2
    Last Post: 21st September 2008, 21:19
  5. Access an object from another file.
    By cbarmpar in forum General Programming
    Replies: 1
    Last Post: 6th September 2008, 23:17

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.