Search code examples
pythonpysideqlistwidget

PySide.QtGui.QListWidget' object has no attribute 'setItemSelected'


Extremely confused here... trying to select all items in a QListWidget. Strangely enough I have done this before fine with this code, but this time it is barking back at me?

# Error: 'PySide.QtGui.QListWidget' object has no attribute 'setItemSelected'
# Traceback (most recent call last):
#   File "<maya console>", line 2, in <module>
#   ...............
#     self.locListWidget.setItemSelected(item, True)
# AttributeError: 'PySide.QtGui.QListWidget' object has no attribute 'setItemSelected' # 

    if (sizeDimensionLocators > 0):
        for loc in dimensionLocators:
            self.locListWidget.addItem(loc)

    for i in range(self.locListWidget.count()):
        item = self.locListWidget.item(i)
        self.locListWidget.setItemSelected(item, True)    <---------- Issue Here

Solution

  • QListWidget doesn't have a setItemSelected:

    You can do this though:

    You might also need to review the selection mode: