Results 1 to 4 of 4

Thread: Can not read qml property from C++ when property under binding

Threaded View

Previous Post Previous Post   Next Post Next Post
  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 Can not read qml property from C++ when property under binding

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

    I'm trying to read the Mainitem.qml mypref property from C++, but it does not work. Is it because the property is binded?
    I have tried the following (obj being the current *QObject):

    metaObject->property(i).read(obj).toString(); // i is the index of mrprefcolor

    and

    = obj->property("mrprefcolor").toString();

    Any thoughts

    Thanks;

    Mut.
    Last edited by anda_skoa; 1st April 2016 at 08:47.

Similar Threads

  1. property binding in a repeater
    By sedi in forum Qt Quick
    Replies: 6
    Last Post: 2nd April 2015, 07:45
  2. Replies: 1
    Last Post: 24th November 2014, 08:28
  3. Dynamic QML Property Binding
    By EMCEE in forum Qt Quick
    Replies: 1
    Last Post: 30th August 2012, 11:51
  4. QML Property Binding update does not propagate
    By bluestreak in forum Qt Quick
    Replies: 0
    Last Post: 21st August 2012, 19:24
  5. Replies: 0
    Last Post: 17th October 2011, 13:07

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