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

Emitting dataChanged from QAbstractListModel using specific roles prevents QML Delegates from updating

    XMLWordPrintable

Details

    Description

      I'm not sure if this is a bug or not, but it certainly surprised me.

      When changing my model and emitting the `dataChanged` signal, the only way I could get the delegate in the QML list view to update was remove the specific roles from the `dataChanged` method call.

       

      To reproduce: Run the attached example, click a color box, drag the crosshairs on the dialog to change the color, and select OK will change the model. The QML delegate will not update.

      If you change line 48 of the attached `photomodel.cpp` to emit `dataChanged` with just the indexes, the QML delegate will update as the underlying model changes as expected. 

       

       

      Attachments

        1. qml.qrc
          0.1 kB
        2. photomodel.h
          0.7 kB
        3. photomodel.cpp
          10 kB
        4. model.pro
          1 kB
        5. main.qml
          3 kB
        6. main.cpp
          0.7 kB
        7. crosshairs.png
          crosshairs.png
          0.9 kB
        8. colorpicker.h
          0.5 kB
        9. colorpicker.cpp
          10 kB
        10. 68001.zip
          8 kB

        Issue Links

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

          Activity

            People

              shausman Simon Hausmann
              benhoff Ben Hoff
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes