def keyPressEvent(self, event):
if event.key() == QtCore.Qt.Key_Delete:
current_item = self.lstWdg_Darsteller.currentItem()
if current_item is not None and current_item.isSelected():
self.lstWdg_Darsteller.takeItem(self.lstWdg_Darsteller.currentRow())
current_item = self.lstWdg_Darstellerin.currentItem()
if current_item is not None and current_item.isSelected():
self.lstWdg_Darstellerin.takeItem(self.lstWdg_Darstellerin.currentRow())
aus dem Darstellerin Widget löscht er ein Item
bei Darsteller Widget löscht er aus beiden das letzte Item
wieso und wie kriege ich es hin das er jeweils aus dem Selected Widget das Item löscht ?
Danke !
def keyPressEvent(self, event):
if event.key() == QtCore.Qt.Key_Delete:
if self.lstWdg_Darsteller.hasFocus():
current_item = self.lstWdg_Darsteller.currentItem()
if current_item is not None and current_item.isSelected():
self.lstWdg_Darsteller.takeItem(self.lstWdg_Darsteller.currentRow())
if self.lstWdg_Darstellerin.hasFocus():
current_item = self.lstWdg_Darstellerin.currentItem()
if current_item is not None and current_item.isSelected():
self.lstWdg_Darstellerin.takeItem(self.lstWdg_Darstellerin.currentRow())
Danke Axel, hatte es mit Hilfe von chatgpt auch gefunden. Allerdings nach vielen fragen erst. Genau das hasFocus hatte mir gefehlt. Alle Befehle kenne ich ja auch nicht