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

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.