Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. [SOLVED] Find item in Stackview that has been pushed onto it as URL

[SOLVED] Find item in Stackview that has been pushed onto it as URL

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 3.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    CarolaC
    wrote on last edited by
    #1

    Hello,

    is there a possibility to address an item in a stackview that has been pushed onto it as URL? I used the following code:

    @stackView.push( {item: Qt.resolvedUrl("Test.qml")} );@

    In my application, I push a lot of qml-files onto the Stackview with this method. Now I want to unwind the stack to certain positions or find certain items in the stack, but I don't know the item names. The following code does not work:

    @stackView.pop( {item: Qt.resolvedUrl("Test.qml")} );@

    Is there a solution for this? I don't want to work with the index because when my program changes, the index of an item in the stack could also change.

    Thank you.

    1 Reply Last reply
    0
    • Z Offline
      Z Offline
      z.emb
      wrote on last edited by
      #2

      You can search for specific items on a StackView with the find() method.
      For example this should work (not tested):

      @var item = stackView.find(function(item, index) { return item.objectName === "TestPage" })
      stackView.pop(item);
      @

      Of course you have to set the objectName when you push the item:
      @stackView.push( {item: Qt.resolvedUrl("Test.qml"), properties: { objectName: "TestPage" }} );@

      1 Reply Last reply
      1
      • C Offline
        C Offline
        CarolaC
        wrote on last edited by
        #3

        Thank you so much! I knew that there is a find() method, but I didn't think of using a property as an identifier...

        I changed my code as you suggested and it works perfectly.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved