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] listview with 2 models and back button

[SOLVED] listview with 2 models and back button

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 2.5k 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.
  • A Offline
    A Offline
    Alcatraz
    wrote on 14 May 2012, 21:05 last edited by
    #1

    i have 2 listviews

    1 list view that is an ICON menu

    !http://img220.imageshack.us/img220/8147/step1s.png(Click to see the first listview)!

    and the clicked code is

    @ function iconClicked() {
    subMenuModel.iName = iName
    screen.iName = iName
    screen.iSource = iSource
    previousMenu.append({"name": iName}) //add for the back button
    }@

    then once its clicked

    !http://img254.imageshack.us/img254/3551/step2xf.png(Click to see second listview)!

    and the clicked code for that is

    @ function iconClicked() {
    screen.iName = sName
    screen.iSource = sSource
    subMenuModel.iName = iName
    previousMenu.append({"name": sName}) //add for the back button
    }@

    and previousMenu has what ever you clicked on currently so if you clicked on store 1 thats what would append now i want to be able to click my back button but onClicked get the size of the list go to the last one delete and read the text if the back button is clicked again get the new size of the list then read the text of the last one in the list

    how would i do such thing ?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      Alcatraz
      wrote on 13 Jun 2012, 20:31 last edited by
      #2

      Edit: i solved my issue with a back button for anyone else wanting to know how i fixed this was

      @
      ListModel {
      id: itemModel
      function itemRequested(item)
      {
      append({"item": item})
      menuModel.topLevelName = item
      }
      function itemLast()
      {
      if (count != 0)
      remove(count - 1)

              if (count - 1 <= 0)
              {
                  toolBar.activateBack = true
              }
      
              if (count != 0)
              {
              var itemName = get(count - 1).item
              contentZone.sendData2model = itemName
              }
          }
      }
      

      @

      when items are clicked @ itemModel.itemRequested(myString)@

      and when the back buttin is clicked @itemModel.itemLast()@

      1 Reply Last reply
      0
      • B Offline
        B Offline
        brents1
        wrote on 5 Jul 2012, 13:40 last edited by
        #3

        I'm trying to implement someting similar with nested menus and have not found much. Can you post the basic qml needed to implement this? Thanks!

        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