Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-84093

DelegateChooser doesn't update when DelegateChoice criteria are modified

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Reported
    • Priority: P3: Somewhat important
    • Resolution: Unresolved
    • Affects Version/s: 5.14.2
    • Fix Version/s: None
    • Labels:
      None
    • Platform/s:
      All

      Description

      I was trying to use DelegateChooser to show the current item in a ListView radically different than the not-current items, and DelegateChooser seemed to be the right choice for the task. 

      Using a setup like this:

      ListView {
          id: view
          model: someModel
          delegate: chooser
      }
      
      DelegateChooser {
          id: chooser
          DelegateChoice {row: view.currentIndex; delegate: currentDelegate}
          DelegateChoice {/* default */; delegate: normalDelegate}
      }
      
      Component {
         id: normalDelegate
         // stuff, including setting view.currentIndex on clicking on it
      }
      
      Component {
         id: currentDelegate
         // very different stuff
      }

      There is nothing in the documentation of DelegateChooser to suggest this should not work, but it doesn't.

      Reading the source code of DelegateChooser and DelegateChoice, that is not all that suprising I guess. DelegateChoice has signals signalling changes, but it seems that DelegateChooser doesn't listen to these signals. 

      However, I also tried a work-around where I make the model emit a dataChanged signal for the affected rows in an attempt to force a re-evaluation of `QmlDelegateChoice::match`, but that also does not result in a change of delegate used for the items. 

      It seems that as it stands, DelegateChooser and DelegateChoice are only suitable for scenario's where both the criteria and the data are static, as no updates are processed. 

        Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            Assignee:
            qt.team.quick.subscriptions Qt Quick and Widgets Team
            Reporter:
            andre André Somers
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:

                Gerrit Reviews

                There are no open Gerrit changes