Important: Please read the Qt Code of Conduct -

Access exported property

  • Access exported property
    I am making an app for mobile devices with Qt 5.8 on OS X 10. Starting with a Qt Quick wizard template, using SwipeView, I for instance want changes to have been made also in a textField2 on Page2 when I click a button1 on Page1. In design mode I have exported button1 and thus have "property alias button1: button 1" in Page1Form.ui.qml. In Page2.qml I have "Page1Form.button1.onClicked: {textField2 = ...}", which is formally accepted, but does not work.
    I have searched all Qt documentation and forums without success. The closest idea I have seen is to use the model "attachedObjects: [ Page1Form {id: page1Form} ]" in Page2.qml, but I can't get that accepted.
    How should I do?

  • @PA-F You can try to bind textField2's text directly to some text property of another item. If you have textField1 in Page1, make alias for the textField1 and bind textField2.text: textField1.text.

    The problem with your code may be that you bind button1.onClicked twice and the binding in Page1 replaces the binding in Page2 (if you have button1.onClicked in Page1, too).

  • Thanks for a good explanation and suggestion! Using the concept you suggest still seems to be clumsy -- it doesn't work without declaration of further properties in both directions. I will try to use model/view concepts instead (

Log in to reply