You mixed the signals:
deleteButton.connect(deleteButton,QtCore.SIGNAL('itemClicked(clicked)'),lambda: self.remove)
deleteButton
is a QPushButton
, but itemClicked(clicked)
looks like the signal from QListWidget
with wrong signature. Since, QPushButton
doesn't have this signal, no connection is made. Qt doesn't raise errors for failed connections, but .connect
method has a bool
return value indicating success/failure of the attempted connection.
Also, lambda: self.remove
as a slot doesn't make sense. Slot should be a callable that is called upon signal emit. Sure, lambda
creates a function, but all you do is reference the method self.remove
. lambda
will be called, self.remove
not. Just self.remove
as a slot is enough.
You should use clicked()
signal (or clicked(bool)
, if you care about the checked
value) from button:
deleteButton.connect(deleteButton, QtCore.SIGNAL('clicked()'), self.remove)
Edit
Another problem: Your remove
method doesn't do what you want. removeItemWidget
doesn't remove the item, it removes the widget inside the item (if you set one). It's counterpart to setItemWidget
.
You should use takeItem
to remove items.
def remove(self):
self.qList.takeItem(self.qList.currentRow())