Important: Please read the Qt Code of Conduct -

[SOLVED]binding from C++: value can not updated automatically

  • hi.
    i implemented my own Object derived class and embeded it to qml context. Code as

    class my_class : public QObject
    Q_PROPERTY(QString vlist MEMBER vlist NOTIFY vlistch)
    QString vlist;

    public slots:
    void change_vlist();
    void vlistch();


    QQmlContext* ctx = engine->rootContext();

    my_class fm;





    text:my_class_fm.vlist // value can not automatically updated, why?



    when i changed the value of "vlist" into qml direcly, "text" property automatically updated.

    But i changed vlist internally via called member function which change the value then "text" property

    not updated automatically. i wonder why? is this a threading issue? is there another way to succeed?


  • Did you emit your @vlistch()@ signal when doing the internal change?

  • not. am i have to do it?

  • yes .thanks.

  • I must admit I'm not a big fan of the MEMBER decorator. You might be interested in my AUTO_PROPERTY macro. I wrote up my reasoning and links to the macro code in "this blog post": In addition to keeping your private implementation details private, it writes the notify signal for you.

Log in to reply