fromComboBox = QComboBox() 添加一個 combobox
fromComboBox.addItem(rates) 添加一個下拉選項
fromComboBox.addItems(["%d years" % x for x in range(2, 26)]) 從序列中添加
fromComboBox.setMaxVisibleItems(10) #設定最大顯示下列項 超過要使用捲軸拖拉
fromComboBox.setMaxCount(5) #設定最大下拉項 超過將不顯示
fromComboBox.setInsertPolicy(QComboBox.InsertAfterCurrent) #設定插入方式
插入方式有:NoInsert,InsertAtTop,InsertAtCurrent,InsertAtBottom,InsertAfterCurrent
InsertBeforeCurrent,InsertAlphabetically
字面意思都好理解 最後一個是按字母表順序插入
QComboBox 發出一個currentIndexChanged(int) 的訊號.
QComboBox 得到當前項 currentIndex() + 1 #QComboBox 預設的currentIndex為 -1
setCurrentIndex可以來設定當前的項
QVariant QComboBox::itemData ( int index, int role = Qt::UserRole ) const 返回給定index處的資料
QComboBox.findText('dsfds') #返回 內容為dsfds的索引
QComboBox.setEditText()設定下拉式清單要顯示的可編輯內容
QComboBox 得到當前項常值內容 currentText()
fromSpinBox = QDoubleSpinBox()
fromSpinBox.setRange(0.01, 10000000.00)
fromSpinBox.setSuffix(" %d") #設定尾碼 如顯示 10.0%d
fromSpinBox.setPrefix('#d') #設定首碼
fromSpinBox.setValue(1.00) 設定值
QDoubleSpinBox 發出 valueChanged(double) 訊號 有setValue(double)插槽
當QComboBox當前項發生變化時候,它會發出訊號currentIndexChanged(int i),i是改變後當前項的下標,可以編寫SLOT來處理