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

QTreeView and QTableView not updating properly after columns of the underlying model change

    XMLWordPrintable

Details

    Description

      After inserting or removing columns from the underlying model the views attached to it does not update properly unless user manually forces them to update (e.g. hovers over them).

      It seems very similar to QTBUG-31028 although that is claimed to be fixed in Qt 5.3 RC-1.

      Attached demonstration project
      The attached project demonstrates the issue. It shows two QTreeViews (however it applies to QTableView as well) one set to QStandardItemModel and the other to QIndentityProxyModel with the standard model as source. Clicking the models will store the index which is then used in buttons that manipulates the structure.

      While manipulating rows works fine manipulating columns will make both views act oddly.

      No function that should cause the view to updated/repainted remedies the issue. The only thing working is resetting or as is the work-around in QTBUG-31028 set the model anew. Obviously both work-arounds scrap the current selection, collapses the tree structure and are potentially expensive operations.

      Investigation of the issue
      Upon investigating the issue further I have found out the likely source. Documentation shows that the QTreeView class handles only rowsAboutToBeRemoved/Inserted() signals from the model but not columnsAboutToBeRemoved/Inserted(). Instead it handles only changes to column count (judging from the protected slot columnCountChanged()). It would in fact explain the behaviour because the header seems to change after columns were removed/inserted while the content of the view remains unchanged until updated due to user action (e.g. hovering over etc.).

      This issue is severely limiting the external updates to the underlying model (via network for instance) as the changes are not reflected by the views properly when they involved changes to columns structure. Second problem is posed for proxy views that performs mapping from rows to columns or vice versa as their behaviour in standard views is odd due to this bug.

      Attachments

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

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            resurrection Michael Vlach
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes