qcombobox

Can a QComboBox display a different value than whats in it's list?

限于喜欢 提交于 2020-08-25 07:27:11
问题 Using Qt 5.9 on Linux, I have a QComboBox with several labels. qc = new QComboBox; qc->addItem(tr("Red")); qc->addItem(tr("Green")); qc->addItem(tr("Blue")); Lets say a user activates the QComboBox and the 3 color labels are shown in the drop down list. The user then selects the 1st item (red). What I want to do is have the QComboBox display a different value than what was selected. I.e., if red is selected, then a number is shown, possibly 1 for the first item (or it could be an R for Red),

Can a QComboBox display a different value than whats in it's list?

淺唱寂寞╮ 提交于 2020-08-25 07:27:09
问题 Using Qt 5.9 on Linux, I have a QComboBox with several labels. qc = new QComboBox; qc->addItem(tr("Red")); qc->addItem(tr("Green")); qc->addItem(tr("Blue")); Lets say a user activates the QComboBox and the 3 color labels are shown in the drop down list. The user then selects the 1st item (red). What I want to do is have the QComboBox display a different value than what was selected. I.e., if red is selected, then a number is shown, possibly 1 for the first item (or it could be an R for Red),

how to mark current item text in QComboBox?

 ̄綄美尐妖づ 提交于 2020-07-09 11:49:31
问题 I'm using a combo box as a simple command line with a history. Here's the signal-slot definition: QtWidgets.QShortcut(QtGui.QKeySequence(QtCore.Qt.Key_Return), self.comboBox_cmd, activated=self.queryLine) ...and the slot: @QtCore.pyqtSlot() def queryLine(self): ''' Read cmd string from widget and write to device. ''' ## comboBox can be enhanced with a history cmd = self.comboBox_cmd.currentText() cmds = [self.comboBox_cmd.itemText(i) for i in range(self.comboBox_cmd.count())] if not cmds or

how to mark current item text in QComboBox?

被刻印的时光 ゝ 提交于 2020-07-09 11:48:12
问题 I'm using a combo box as a simple command line with a history. Here's the signal-slot definition: QtWidgets.QShortcut(QtGui.QKeySequence(QtCore.Qt.Key_Return), self.comboBox_cmd, activated=self.queryLine) ...and the slot: @QtCore.pyqtSlot() def queryLine(self): ''' Read cmd string from widget and write to device. ''' ## comboBox can be enhanced with a history cmd = self.comboBox_cmd.currentText() cmds = [self.comboBox_cmd.itemText(i) for i in range(self.comboBox_cmd.count())] if not cmds or