I am working on an application in PyQt that accepts a dictionary of objects and allows you to build variable flows from a robot in real time. One of the things I'm working on to enable this is the drop down menu. Unfortunately, we have a couple of hundred variables, so my PyQt Combobox pops up from the top of the screen to the bottom with items when clicked. I would like to limit the number of elements displayed simultaneously to 20, with the ability to scroll to see the rest. I tried using the documented setMaxVisibleItems method, but it doesn’t affect the dropdown at all. Any recommendations?
The code is here:
from PyQt4.QtCore import Qt
from PyQt4.QtGui import QComboBox, QApplication
from cli.parc2_od import cli_od
import sys
app = QApplication(sys.argv)
items = cli_od.OD.keys()
combo = QComboBox()
combo.setStyleSheet("QComboBox { combobox-popup: 0; }")
combo.setMaxVisibleItems(10)
combo.addItems(items)
combo.resize(300, 30)
combo.show()
sys.exit(app.exec_())
source
share