我想知道如何让QComboBox
下拉菜单保持打开状态。
from PyQt4 import QtCore, QtGui
app = QtGui.QApplication([])
class Combo(QtGui.QComboBox):
def __init__(self, *args, **kwargs):
super(Combo, self).__init__()
self.addItems(['Item_1','Item_2','Item_3','Item_4','Item_5'])
self.show()
tree=Combo()
sys.exit(app.exec_())
答案 0 :(得分:1)
为了使QComboBox
的下拉菜单保持打开,请覆盖其内置的hidePopup()
方法。
from PyQt4 import QtCore, QtGui
app = QtGui.QApplication([])
class Combo(QtGui.QComboBox):
def __init__(self, *args, **kwargs):
super(Combo, self).__init__()
self.addItems(['Item_1','Item_2','Item_3','Item_4','Item_5'])
self.show()
def hidePopup (self):
pass
inst=Combo()
sys.exit(app.exec_())