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} })

    and Profile.qml has a Flickable as the root parent if it matters.

    What am i missing? I'm new to Qt.

  • Qt Champions 2017

    See if u can convert profile.qml to URL by qt.resolvedurl and then pass to item while pushing

  • Nope.. still getting

    QML StackView: push: nothing to push
    stackView.push({item:Qt.resolvedUrl(":/Profile.qml"), properties:{user_info:user_data} })

  • stackView.push(["qrc:/Profile.qml", {user_info:user_data}] )

    Solved my issue.. i suppose my issue is a bug..

  • 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: (Controls 1) (Controls 2)

Log in to reply

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