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. ListView problems
Forum Updated to NodeBB v4.3 + New Features

ListView problems

Scheduled Pinned Locked Moved Solved QML and Qt Quick
2 Posts 1 Posters 234 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
    Circuits
    wrote on last edited by
    #1

    I am working with this wizard and it is using ListView. The inherent problem here is that the user's selection may change the model data which in turn changes the ListView delegate components causing the currentIndex to be reset to zero. Therefore, I added in some memory:

    ///Save the last index when "next" button is clicked
    onClicked:
    {
      setupList.incrementCurrentIndex()
      currentSelectedVehicle.setConfigurationResumeStep(setupList.currentIndex)
    }
    
    //When model resets
    onModelChanged:
    {
      setupList.currentIndex = currentSelectedVehicle.lastConfigurationStep
      setupList.positionViewAtIndex(setupList.currentIndex, ListView.Beginning)
    }
    

    this does keep everything from going backwards whenever the model changes. However, I wanted to add a feature to reduce button presses. In other words, I didn't want the user to have to click next every time they make a selection.

    So, in the delegate, I created a signal called progressWizard:

    signal progressWizard
    

    which will fire whenever the user makes a "acceptable" selection from one of the many components that could potentially be loaded. I am catching that signal in the delegate defintion:

    delegate: Item
      {
        id: buffer
    
        HardwareSettingsDisplay
        {
          anchors.fill: parent
          title: modelData.label
          onProgressWizard:
          {
            setupList.incrementCurrentIndex()
            currentSelectedVehicle.setConfigurationResumeStep(setupList.currentIndex)
          }
        }
      }
    

    as you can see it's the same logic seen in the "next" button. This works great except whenever the user makes a selection that changes the model data. When that happens I get this error:

    ReferenceError: progressWizard is not defined

    coming from within the delegate. Any idea what I am doing wrong here?

    1 Reply Last reply
    0
    • C Offline
      C Offline
      Circuits
      wrote on last edited by
      #2

      I have a tentative solution. If I add a Connections to the modelData inside the individual component and then toggle progressWizard() onValueChanged it works. I am not sure if this is the best solution. If no one tells me otherwise here in the next few days then I will mark this as solved and move on.

      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