Reputation: 469
I want to know how to trigger the function "self.runEverything" when a specific item in a list widget is selected. I tried this but nothing is happening because I am not entering the if-statement.
if(self.listwidget.item(0).isSelected()):
self.runEverything(filepath)
Upvotes: 1
Views: 1232
Reputation: 413
You may want to check QListWidget currentRowChanged signal.
So, depending on the thing you want:
# example call
# QListWidget::currentRowChanged() emits an int value.
self.listwidget.currentRowChanged.connect(self.slotOrLambdaFunction)
def slotOrLambdaFunction(self, idx : int):
if idx == 0:
self.runEverything(filePath)
And then trigger stuff you need from the currently selected row in the widget.
You can also use QListWidget::itemClicked(QListWidgetItem item)
.
Upvotes: 1