Updating property by value in QML
-
I have a main screen that pushes another screen on top of it via a button click.
In my
main.qml, I have some custom component, example:ScreenOne { id: screenOne } ScreenTwo { id: screenTwo } StackView { id: stackView Componenet,onCompleted: { // load welcome screen and then load ScreenOne } }ScreenTwohas a default Boolean property as:Item { property bool isUser: false }In
ScreenOneI have a button that does something like this:screenTwo.isUser = true stackView.push(screenTwo, StackView.Immediate)For some reason the value of
isUsernever changes even after setting its value. How should I make sure that this happens?Any help on this is appreciated.
-
Figured it out.
Send in the properties via push.
Example:
stackView.push(screenTwo, {"isUser": true}, StackView.Immediate)More on this is at https://doc.qt.io/qt-5/qml-qtquick-controls2-stackview.html#push-method