Python PyQt4-如何制作按钮以删除组合框中的选定项?
我正在为一个程序制作一个GUI,需要有人将项目添加到列表中进行选择。这很管用,但我想他们可能想删除和删除该项目,因为他们改变了主意。所以我想做一个按钮,实现这一点Python PyQt4-如何制作按钮以删除组合框中的选定项?,python,python-3.x,pyqt4,Python,Python 3.x,Pyqt4,我正在为一个程序制作一个GUI,需要有人将项目添加到列表中进行选择。这很管用,但我想他们可能想删除和删除该项目,因为他们改变了主意。所以我想做一个按钮,实现这一点 ......class code and stuff self.delFuncBttn.clicked.connect(lambda:self.delFunc) #The button that I want to delete the selected item badFunc = self.funcCB.currentText()
......class code and stuff
self.delFuncBttn.clicked.connect(lambda:self.delFunc) #The button that I want to delete the selected item
badFunc = self.funcCB.currentText() #This is how i retrieve the currently selected text
funCB.removeItem(badFunc)#Trying to remove it with this method I found in the documentation
是否有其他方法来做我想做的事情,或者我使用的方法是错误的?我们将不胜感激。提前谢谢。我会把整个代码,但它是很多,有点混乱,我想。我所给予的是我用来尝试完成我想要的事情的东西。qcombox.removietem需要一个整数,表示要删除的项的索引。它不希望删除该项的文本。可以使用self.funcb.currentIndex获取当前索引。将其传递给removeItem应该可以使代码正常工作。我这样做了……它不会让我缩进。def delFuncself:/n badFunc=self.funcb.currentText/n p=self.funcb.currentIndexbadFunc/n funcb.removietemp