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

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

XMLWordPrintable

      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. 

       

       

        1. 68001.zip
          8 kB
        2. colorpicker.cpp
          10 kB
        3. colorpicker.h
          0.5 kB
        4. crosshairs.png
          crosshairs.png
          0.9 kB
        5. main.cpp
          0.7 kB
        6. main.qml
          3 kB
        7. model.pro
          1 kB
        8. photomodel.cpp
          10 kB
        9. photomodel.h
          0.7 kB
        10. qml.qrc
          0.1 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

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

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes