アイテムを含むコンボボックスがあり、アイテムを選択せずに表示したいだけです。Qt Designer で検索しましたが、適切なプロパティが見つかりません。何か案は ?
1062 次
2 に答える
2
QComboBox.setEditable(False)
それを行う必要があります: http://pyqt.sourceforge.net/Docs/PyQt4/qcombobox.html#setEditable
于 2013-08-03T11:16:26.540 に答える
2
currentIndexChanged
ユーザーが選択したものに関係なく、古い値を元に戻す関数に信号を接続する必要がある QtDesigner では実行できません。
例:
PyQt4 から sys をインポート QtGui、QtCore をインポート
class MainWidget(QtGui.QWidget):
def __init__(self):
super(MainWidget, self).__init__()
# Create a combo and set the second item to be selected
self.combo = QtGui.QComboBox()
self.combo.addItems(['foo', 'bar', 'baz'])
self.combo.setCurrentIndex(1)
# Connect the combo currentIndexChanged signal
self.combo.activated.connect(self.on_combo_change)
# Setup layout
self.layout = QtGui.QVBoxLayout()
self.layout.addWidget(self.combo)
self.setLayout(self.layout)
def on_combo_change(self, index):
# Whatever the user do, just ignore it and revert to
# the old value.
self.combo.setCurrentIndex(1)
app = QtGui.QApplication(sys.argv)
mw = MainWidget()
mw.show()
app.exec_()
于 2013-08-10T17:07:50.867 に答える