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

DelegateChooser doesn't update when DelegateChoice criteria are modified



    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.14.2
    • None
    • All


      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. 


        Issue Links

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



              richard Richard Moe Gustavsen
              andre André Somers
              4 Vote for this issue
              14 Start watching this issue



                Gerrit Reviews

                  There are no open Gerrit changes