Results 1 to 4 of 4

Thread: Acessing individual properties of nested QML object from C++

  1. #1
    Join Date
    Apr 2014
    Posts
    125
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Android Maemo/MeeGo

    Question Acessing individual properties of nested QML object from C++

    ---------- Mainitem.qml
    Qt Code:
    1. import QtQuick 1.0
    2.  
    3. Item1 {
    4. width: 100; height: 100
    5.  
    6. ItemA1 {
    7. id: square
    8.  
    9. Rectangle {
    10. color: "red"
    11. width: 10
    12. height: 10
    13. }
    14. }
    15.  
    16. itemB {}
    17. }
    To copy to clipboard, switch view to plain text mode 
    ---------- itemB.qml -------------
    Qt Code:
    1. import QtQuick 1.0
    2.  
    3. Item2 {
    4. property length: 6
    5.  
    6. ItemB1 {
    7. id: idc
    8.  
    9. Rectangle {
    10. color: "red"
    11. width: 10
    12. height: 10
    13. property rectype: 0
    14. }
    15. }
    16.  
    17. }
    To copy to clipboard, switch view to plain text mode 
    Hello;

    How to read the properties of ItemB1 Rectangle (e.g rectype) from my C++ code (we know only the path to Mainitem.qml)?

    Thanks;

    Mut
    Last edited by anda_skoa; 25th March 2016 at 10:15. Reason: missing [code] tags

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,420
    Thanks
    37
    Thanked 1,545 Times in 1,495 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Acessing individual properties of nested QML object from C++

    Standard question: why do you want do invert the dependency direction and make C++ depend on specific QML?

    Cheers,
    _

  3. #3
    Join Date
    Apr 2014
    Posts
    125
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Android Maemo/MeeGo

    Default Re: Acessing individual properties of nested QML object from C++

    Thanks for the reply.
    I want to keep my .qml files but I want to access its data (the properties of the qml) from my C++ class?
    Thanks
    Mut

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,420
    Thanks
    37
    Thanked 1,545 Times in 1,495 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Acessing individual properties of nested QML object from C++

    Sorry, misunderstanding, I'll try to rephrase.

    Making the C++ part of an application dependent on certain QML code is usually a bad idea, as it puts restrictions on the QML side that are often unnecessary.

    What do you want to do that you think requires to access QML objects from C++?

    Cheers,
    _

Similar Threads

  1. Replies: 5
    Last Post: 10th January 2014, 16:20
  2. Replies: 7
    Last Post: 8th January 2014, 01:03
  3. Replies: 4
    Last Post: 2nd October 2012, 17:39
  4. Mapping JS Object properties to QProperties
    By Scorp2us in forum Qt Programming
    Replies: 0
    Last Post: 29th June 2009, 20:52
  5. Acessing other objects "higher up"
    By CryoGenFX in forum Newbie
    Replies: 4
    Last Post: 17th October 2007, 19:55

Tags for this Thread

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.