ID 239283 - Exceptions when showing a `UI4.Widgets.SortableListWidget` instance to which items have been added by calling `addItem()` or `addItems()`

Follow

Problem summary:

The UI4.Widgets.SortableListWidget class has been designed to work with UI4.Widgets.SortableListWidgetItem instances as items. When attempting to use functions of the underlying QtGui.QListWidget class, exceptions may occur due to the absence of certain functions on the items that are created.

Steps to reproduce:

  1. Execute the following snippet of code in a Python tab:
    • 
      sortableListWidget = UI4.Widgets.SortableListWidget(None)sortableListWidget.addItem('Item 1')sortableListWidget.show()

The same problem affects items added via addItems(), e.g.

  • 
    sortableListWidget = UI4.Widgets.SortableListWidget(None)sortableListWidget.addItems(['Item 1', 'Item 2', 'Item 3'])sortableListWidget.show()

Expected behaviour:

The SortableListWidget is shown as a stand-alone widget in a window by itself, containing the items that were added.

Actual behaviour:

Exceptions are raised, with tracebacks similar to the following:


    Traceback (most recent call last):      File ".../bin/python/UI4/Widgets/SortableListWidget.py", line 392, in sizeHint        return item.calcSizeHint()    AttributeError: 'QListWidgetItem' object has no attribute 'calcSizeHint'

Workaround:

Items in UI4.Widgets.SortableListWidget instances can be created as follows:


item1 = UI4.Widgets.SortableListWidgetItem(sortableListWidget, 'Item 1')

Reproduced versions/platforms:

  • 1.0v1/Linux
  • 2.5v3/Linux

Customer version/platform:

2.5v3/Linux

    We're sorry to hear that

    Please tell us why