PySide.QtGui.QListWidget'对象没有属性'setItemSelected'
PySide.QtGui.QListWidget' object has no attribute 'setItemSelected'
这里非常困惑...试图 select QListWidget 中的所有项目。奇怪的是,我以前用这段代码做过这个,但这次它对我狂吠?
# 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
QListWidget 没有 setItemSelected
:
- https://srinikom.github.io/pyside-docs/PySide/QtGui/QListWidget.html#PySide.QtGui.QListWidget
- http://doc.qt.io/archives/qt-4.8/qlistwidget.html#selectedItems
不过你可以这样做:
item.setSelected(true)
- http://doc.qt.io/qt-5/qlistwidgetitem.html#setSelected
您可能还需要查看选择模式:
这里非常困惑...试图 select QListWidget 中的所有项目。奇怪的是,我以前用这段代码做过这个,但这次它对我狂吠?
# 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
QListWidget 没有 setItemSelected
:
- https://srinikom.github.io/pyside-docs/PySide/QtGui/QListWidget.html#PySide.QtGui.QListWidget
- http://doc.qt.io/archives/qt-4.8/qlistwidget.html#selectedItems
不过你可以这样做:
item.setSelected(true)
- http://doc.qt.io/qt-5/qlistwidgetitem.html#setSelected
您可能还需要查看选择模式: