QComboBox用法小結

來源:互聯網
上載者:User

 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來處理

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.