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

ComboBox deletes delegate components

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.8
    • Quick: Controls 2
    • None
    • All

    Description

      When setting a new delegate component ComboBox deletes the previous one. https://code.qt.io/cgit/qt/qtdeclarative.git/tree/src/quicktemplates/qquickcombobox.cpp#n1396

      It doesn't own the component and taking ownership in this fashion makes it impossible to change between delegates. Deleting the existing delegate before setting the new one on the QQmlDelegateModel nullifies the pointer in the delegate model putting it in a state where it doesn't recognize it needs to inform views that the items associated with the old delegate have been removed, just that new items associated with the new delegate have been inserted doubling the number of perceived items in the view. And the delegate being destroyed means it cannot be reused later or shared with other items.

      Working around this by dynamically allocating a Component object doesn't work because it doesn't solve the old component being destroyed before the new one is set on the delegate model, so you end up with duplicate items.

      Using a QQmlAbstractDelegateComponent as a proxy item doesn't work because QQmlDelegateModel will notify the views that all the items have been removed and new ones inserted on the delegateChanged() signal. But ListView acquires inserted objects before releasing removed ones and the delegate model doesn't invalidate the internal objects so the view ends up getting a new reference to already created items instead of an object created from the new delegate.

      Assigning a DelegateModel to the model property will work but pushes the issue onto all consumers of a ComboBox derivative type.

      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
            andrew.den.exter Andrew den Exter
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes