Results 1 to 5 of 5

Thread: How to access root context property from instantiated C++ QObject

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2014
    Posts
    16
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default How to access root context property from instantiated C++ QObject

    On the C++ side I do this:
    Qt Code:
    1. rootContext()->setContextProperty("foo", fooObject);
    To copy to clipboard, switch view to plain text mode 

    Then in Qml I do this:
    Qt Code:
    1. Item {
    2. MyCPlusPlusObject { }
    3. Text {
    4. text: foo.someTextProperty
    5. }
    6. }
    To copy to clipboard, switch view to plain text mode 
    Where MyCPlusPlusObject is a simple QObject based C++ object that is registered with qmlRegisterType. The question is how can I get a hold of the "foo" context property from inside the implementation of MyCPlusPlusObject. I need to somehow get a hold of the root context to get the property out of it.
    Last edited by don@thegagnes.com; 10th April 2015 at 23:24.

Similar Threads

  1. how to access QAxObject property?
    By 0BLACK0 in forum Qt Programming
    Replies: 0
    Last Post: 17th February 2015, 11:53
  2. Replies: 0
    Last Post: 23rd May 2014, 18:01
  3. Access instantiated objects from C++
    By Sunny31 in forum Qt Quick
    Replies: 3
    Last Post: 5th December 2010, 17:25
  4. How to get a pointer to a QObject's property ?
    By HiJack in forum Qt Programming
    Replies: 7
    Last Post: 28th August 2010, 10:54
  5. Replies: 0
    Last Post: 16th April 2007, 12:18

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
  •  
Qt is a trademark of The Qt Company.