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

Unlikely Warning setSelectionModel() while the models are the same

    XMLWordPrintable

Details

    • Bug
    • Resolution: Cannot Reproduce
    • P3: Somewhat important
    • None
    • 5.13, 5.14, 6.2.4, 5.15
    • Widgets: Itemviews
    • None
    • Linux/Wayland, Linux/X11, macOS, Windows

    Description

      I share a model between two instantiated widgets of the same type. 

      • First, I instantiate the first tableview V1, and set a created model M.
      • Next, I instantiate the second tableview V2. I don´t set a model yet.
      • Later on, I take the model M and do a V2.setModel(M).

      I get the warning:

      Warn : QAbstractItemView::setSelectionModel() failed: Trying to set a selection model, which works on a different model than the view.

      However, when I debug the code, I see that setModel(M) in QAbstractitemView, creates a selectionModel with the just set d->model = M. Next it sets the selectionmodel on the QAbstractItemView and there a check is done on selectionmodel->model() == M. 

      selectionmodel->model() returns the value of a property, which correctly holds the value M. 

      So, there should not be a problem. 

      And there actually is no problem, because although the warning is written, there's no 'return', but the code following the assertion is followed. 

      See attached images.

      • The first image shows Qt Creator in debug mode,  just after the warning has ben written. But the code-'cursor' is next to the check statement. 
      • The next image shows the value of 'd->model' of the QAbstractItemView.
      • The next image shows the value of 'selectionModel->d->model->val', which is equal to 'd->model'.

      So this warning is not correct. 

       

      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
            hansdijkema Hans Dijkema
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes