Search code examples
pythonpyqtselectionqlistwidget

ListWidget: How to click a List Item programmatically


After a QtGui.QListWidget was populated with the list items ( QtGui.QListWidgetItem ) I would like to select a very first list item (just the way it happens when a user clicks on list item with left-click mouse). What command or method would get me there?

EDITED

MyListWidget.setCurrentRow(0) method makes/sets a first list_item current. But it doesn't trigger any functions a list_item could be connected to.... no signal get emitted...


Solution

  • You can use setCurrentRow:

        self.list.setCurrentRow(0)