网站首页 > 博客文章 正文
千呼万唤使出来,抽个空更新一下PyQt5系列。
本期练习ComboBox。
UI设计如下,ctrl+R演示功能为预运行如下:
运行演示1 添加anan到两个comboBox中,如下图:
运行演示2 再次添加candy到两个comboBox中,如下图:
运行演示3 从combo Box中选中anan,获取并赋值给lineEdit中:
运行演示4 从combo Box中删除选中anan:
运行演示5 从combo Box2中自动获取选中candy:
选中candy后,将自动复制给自动选中lineEdit.
附代码:
class MainWindow(QMainWindow, Ui_QTtest):
def __init__(self, parent=None):
super(MainWindow, self).__init__(parent)
self.setupUi(self)
self.comboBox_2.currentIndexChanged.connect(self.auto_get)#自动获取combobox选中内容
def auto_get(self):
self.lineEdit_4.setText(self.comboBox_2.currentText())
@pyqtSlot()
def on_pushButton_clicked(self):
filedir = self.openfile()[0]
self.data = pd.read_excel(filedir)
self.lineEdit.setText(filedir)
self.model.setDataFrame(self.data)
@pyqtSlot()
def on_pushButton_2_clicked(self):
getLineEdit1 = self.lineEdit_2.text()
self.comboBox.addItem(getLineEdit1)
self.comboBox_2.addItem(getLineEdit1)#addItems 从list里添加多个选项
@pyqtSlot()
def on_pushButton_3_clicked(self):
getComboBoxContent = self.comboBox.currentText()
self.lineEdit_3.setText(getComboBoxContent)
@pyqtSlot()
def on_pushButton_4_clicked(self):
index = self.comboBox.currentIndex()
self.comboBox.removeItem(index)
猜你喜欢
- 2024-10-24 Qt Examples——QSlider(qt qcompleter)
- 2024-10-24 正点原子I.MX6U嵌入式Qt开发指南:第七章《Qt控件 2》
- 2024-10-24 销售订单管理,Excel表格模板演示
- 2024-10-24 抓大放小,瞅瞅 Qt 的几个基础模块
- 2024-10-24 WPF --- 如何重写WPF原生控件样式?
- 2024-10-24 Python入坑系列-pyside6桌面编程之border边框
- 2024-10-24 1.3 MyFirstWidget代码讲解及实用编程技巧分享
- 2024-10-24 C#知识|.Net控件二次封装之ComboBox下拉框
- 2024-10-24 在WPF 中想要在表格的同一列上显示多个表头
- 2024-10-24 Qt模型视图结构_代理(犀牛缩放视图后看不见模型了)
你 发表评论:
欢迎- 最近发表
- 标签列表
-
- powershellfor (55)
- messagesource (56)
- aspose.pdf破解版 (56)
- promise.race (63)
- 2019cad序列号和密钥激活码 (62)
- window.performance (66)
- qt删除文件夹 (72)
- mysqlcaching_sha2_password (64)
- ubuntu升级gcc (58)
- nacos启动失败 (64)
- ssh-add (70)
- jwt漏洞 (58)
- macos14下载 (58)
- yarnnode (62)
- abstractqueuedsynchronizer (64)
- source~/.bashrc没有那个文件或目录 (65)
- springboot整合activiti工作流 (70)
- jmeter插件下载 (61)
- 抓包分析 (60)
- idea创建mavenweb项目 (65)
- vue回到顶部 (57)
- qcombobox样式表 (68)
- vue数组concat (56)
- tomcatundertow (58)
- pastemac (61)
本文暂时没有评论,来添加一个吧(●'◡'●)