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 } }
ScreenTwo
has a default Boolean property as:Item { property bool isUser: false }
In
ScreenOne
I have a button that does something like this:screenTwo.isUser = true stackView.push(screenTwo, StackView.Immediate)
For some reason the value of
isUser
never 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