如何从QListWidget中删除选定的行/项?(Python/PyQt)
我想知道怎么才能删除QListWidget中当前选中的行/项目?
我用了下面的代码,但没有成功!虽然没有报错,但就是没反应?:
self.QuestionList.takeItem(self.QuestionList.currentRow())
1 个回答
3
takeItem
这个函数需要一个参数,就是 行数。你可以通过 listWidget.row()
这个方法来获取当前的行数。
for item in self.QuestionList.selectedItems():
self.QuestionList.takeItem(self.QuestionList.row(item))