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

Switching to IconMode for a QListWidget/QListView disables reordering via InternalMove

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.11, 5.12.0
    • Widgets: Itemviews
    • None
    • All

    Description

      The ListView / QListWidget has an IconMode, allowing display of linear list elements into a 2d grid.

      While the IconMode works fine for displaying static items, it unfortunately appears to completely change the drag'n'drop behavior: A common UI choice for a QListWidget is allowing the user to re-order widgets, by calling setDragDropMode(QAbstractItemView::InternalMove). This mode will allow the user to drag existing items in the QListWidget / QListView on top of other existing items, with the item being inserted at the existing item's spot, and the existing item and subsequent items automatically being move up in the list.

      Two examples of this use-case can be found on this tutorial page. One using a QListWidget, and the second using a QListView / QAbstractItemModel:

      https://www.walletfox.com/course/qtreorderablelist.php

      However, changing the viewmode to IconMode will completely disable this functionality. Instead, the items can no longer be dragged on top of existing items, but only be dragged to other slots on the grid, and with no moving of items being done either.

      It does not seem correct for the a list view / list widget to change it's behavior so drastically based on a "viewing" mode alone. So this very much seem like a bug in the core list model / view implementation in my opinion.

      The attached .zip (submitted with permission from the author) is a slightly modified version of the QListWidget-based example from the webpage above, where code has been added to the end CustomDialog::createListWidget in order to change the view mode to IconMode.

      The other example which uses QListView / QStringListModel basically has the same problem when enabling IconMode is attempted.

      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
            michel_iwaniec michel_iwaniec
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes