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

QAbstractListModel fails to populate QML model

    XMLWordPrintable

Details

    • macOS, Windows
    • 789f7316b (dev), 6561344dd (dev), cc3d7ef32 (6.8), b2ff845f8 (6.8), dd7d8f38b (6.7), 7c7b222e0 (6.7), 385f7b575 (tqtc/lts-6.5), a90eb9500 (tqtc/lts-6.5), a9af10e1e (dev), 2ea3abed0 (6.8), 8d811bb88 (6.7), 4bd303b2a (tqtc/lts-6.5), 4bb16ce2c (dev)

    Description

      I believe I've discovered a regression in Qt 6.5+ that seems to be a timing issue regarding creation of components and resetting of the list model. My guess is that the class sends a signal about the model having been reset before QML is ready to receive it and for some reason the GridView fails to pick up the data correctly.

      I have attached a minimal project. This runs fine in Qt 6.4.2, displaying 3 green squares with sound names in them, and the console output:

      QML debugging is enabled. Only use this in a safe environment.
      qml: index: 0 name: Clarinet
      qml: index: 1 name: Bassoon
      qml: index: 2 name: Piano
      qml: SoundListModel count: 3
      

      However running the same project in Qt 6.5.3, 6.5.5 or 6.6.3 results in nothing being displayed and the output:

      QML debugging is enabled. Only use this in a safe environment.
      qml: SoundListModel count: 3
      

      Clearly the change in count is getting through but not the change to the actual model.

      In the attached code you'll see a commented out Timer item. If you uncomment this, the GridView populates correctly. My belief is that it causes the model to reset on the next event loop after the QML component has been created, so the signals are correctly picked up.

      For anyone else discovering this issue, the Timer item is a workaround.

      Attachments

        For Gerrit Dashboard: QTBUG-125053
        # Subject Branch Project Status CR V

        Activity

          People

            mitch_curtis Mitch Curtis
            paulmasri Paul
            Votes:
            1 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: