我有一个QcomboBox
,里面有一些物品。窗口小部件启动并显示QcomboBox
中的第一项时。如何通过启动来强制QcomboBox
在列表中显示第三项( Index(2))
?
from PyQt5 import QtWidgets, QtGui
class combo(QtWidgets.QWidget):
def __init__(self, parent = None):
super(combo, self).__init__(parent)
layout = QtWidgets.QHBoxLayout(self)
self.cb = QtWidgets.QComboBox()
self.cb.addItems(["1", "2", "3","4"])
layout.addWidget(self.cb)
if __name__ == '__main__':
import sys
app = QtWidgets.QApplication(sys.argv)
ex = combo()
ex.show()
sys.exit(app.exec_())