PYQT 控制項基本使用

2021-09-02 12:32:48 字數 2288 閱讀 6524

qtgui.qcombobox控制項常用函式:

.additem(string)

#新增字串項到item

.additems(list)

#新增列表或元組元素到item

.clear()

#清除所有item

.clearedittext()

#清除編輯框內容

.count()

#返回item數目

.currentindex()

#返回當前選擇索引,從0開始

.currenttext()

#返回當前選擇內容

.insertitem(index,string)

#插入字串項到item項index後

.insertitems(index,list)

#插入列表或元組元素到item項index後

.insertseparator(index)

#插入分隔符到item項index後

.itemtext(index)

#返回item項index的內容

.removeitem(index)

#刪除item項index

.setcurrentindex(index)

#設定item項index為當前選擇

.seteditable(true)

#設定選框可編輯

.setedittext(string)

#設定編輯框內容

.setitemtext(index,string)

#設定item項index內容為字串值 2

qtgui.qlineedit控制項常用函式:

.backspace()#模擬backspace退格鍵

.clear()

#清除輸入框內容

.cursorposition()

#返回輸入框游標位置,從0開始

.setechomode(echomode)

#設定輸入框顯示格式

#0--normal,1--noecho,2--password,3--passwordechoonedit

.setplaceholdertext(string)

#設定輸入框浮顯文字

.setreadonly(true)

#設定輸入框唯讀

.settext(string)

#設定輸入框內容

.text()

#返回輸入框內容 3

qtgui.qspinbox控制項常用函式:

.setmaximum(max)

#設定最大值

.setminimum(min)

#設定最小值

.setrange(min,max)

#設定範圍

.setsinglestep(step)

#設定步長

.setvalue(num)

#設定輸入框當前值

.value()

#返回輸入框當前值 4

qtgui.qlabel控制項常用函式:

.clear()

#清除標籤內容

.setpixmap(qtgui.qpixmap(path))

#設定標籤內容

.settext(string)

#設定標籤內容文字

.text()

#返回標籤內容 5

qtgui.qlistwidget控制項常用函式:

.additem(string)

#新增字串項到item

.additems(list)

#新增列表或元組元素到item

.clear()

#清除所有item

.count()

#返回item數目

.currentitem()

#返回當前選擇item類,沒選返回none

.currentrow()

#返回當前選擇索引行,從0開始,沒選返回-1

.insertitem(row,string)

#插入字串項到item項row行後

.insertitems(row,list)

#插入列表或元組元素到item項row行後

.item(row)

#返回item項row行的item類

.setcurrentitem(item)

#設定item項item為當前選擇

.setcurrentrow(row)

#設定item項row行為當前選擇

item類方法:

.text()

#返回內容

.settext()

#設定內容

PyQt5控制項的使用

qtablewidget qtabwidget qpixmap 圖表工具qchart 下拉選擇框qcombobox qtablewidget問題列表 空間不夠時單元格文字顯示不全 設定item背景色和字型顏色 場景 當空間不夠時,單元格內容會顯示不完全出現省略號 如下 方案 table object...

pyqt介面控制項

建立主介面的兩種方法 1.通過繼承qtgui.qmainwindow建立類 qtgui.qmainwindow.init self 呼叫父類初始化方法 2.通過繼承qtgui.qwidget建立類 qtgui.qwidget.init self 呼叫父類初始化方法 qpushbutton 按鈕 se...

pyqt 實現控制項移除 pyqt刪除控制項的坑

最近在使用pyqt寫個專案,在remove控制項後,使用findchild仍然能找到控制項,除錯很久,才發現是pyqt的深坑.很無奈 這裡是關閉qtabwidget的標籤 def close tab self,index 1 if index 1 index self.tab widget.curr...