Getting "QML StackView: push: nothing to push" after trying to push a url to stack view
-
I'm trying to push a QML via it's url to a stackView and i am getting
QML StackView: push: nothing to push
the same happens when i try to push a component via it's id on the StackView here is my code:
profilePic.onClicked: { stackView.push({item:"qrc:/Profile.qml", properties:{user_info:user_data} }) console.log(user_data["id"]) }
and Profile.qml has a
Flickable
as the root parent if it matters.What am i missing? I'm new to Qt.
-
See if u can convert profile.qml to URL by qt.resolvedurl and then pass to item while pushing
-
Are you using QtQuick Controls 1 or QtQuick Controls 2?
If QtQuick Control 2, do the following:
stackView.push("qrc:/Profile.qml", {user_info: user_data})
For Controls 1:
stackView.push({item: "qrc:/Profile.qml", properties: {user_info: user_data}})
I think you may be using Controls 2, and the original command you used was for Controls 1. Your solution worked because it is a correct way to use the push function for Controls 2 (although having it as a list isn't necessary since you're only pushing one item)
See the difference between the push function for Controls 1 and Controls 2 in the documentation:
http://doc.qt.io/qt-5/qml-qtquick-controls-stackview.html#push-method (Controls 1)
http://doc.qt.io/qt-5/qml-qtquick-controls2-stackview.html#push-method (Controls 2)