Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to Binding a C++ class member to qml UI element property



  • Can QML Binding type can achieve bind a c++ class member to qml UI property like MS UWP‘s DataBinding

        Binding {
            target: text  // a textblock
            property: "text" //the text property of textblock
            value: viewModel.cnt // a c++ class property exposed to qml
        }


  • You can make C++ members act as properties by using the Q_PROPERTY macro. Check out this page. It makes working between Qml and C++ quite intuitive.


Log in to reply