PyQt组合框更改标签的值
- 作者: 无证斋
- 来源: 51数据库
- 2022-12-19
问题描述
我正在使用 PyQt5 为项目制作 UI.
I'm using PyQt5 to make a UI to a project.
当用户更改组合框的值时,我想更改标签的值.
I want to change the value of a label when the user changes the value of a combo box.
谁能帮我找出用来触发"改变标签值的函数的方法?
Can anyone help me to find out wich method to use to 'trigger' the function that changes the value of the label ?
推荐答案
如果是combo box的信号,当它的值改变时,可以使用
If you mean the signal of combo box, when it's value changed, you can use
QComboBox.currentTextChanged
或
QComboBox.currentIndexChanged
每次用户更改组合框时,都会触发这些信号.
Everytime a combobox is changed by user, these signals will be triggered.
假设 cb_1 是您的组合框父/小部件类中的一个简单函数,例如
Suppose cb_1 is your combobox a simple function in you parent/widget class like
def on_combobox_changed(self, value):
print("combobox changed", value)
# do your code
只是
cb_1.currentTextChanged.connect(self.on_combobox_changed)
尝试更改组合框,看看会发生什么
try to change the combobox and see what will happen
推荐阅读
热点文章
Discord.py(重写)on_member_update 无法正常工作
0
Discord.py 在 vc 中获取用户分钟数
0
discord.py 重写 |为我的命令出错
0
Discord.py rewrite 如何 DM 命令?
0
播放音频时,最后一部分被切断.如何解决这个问题?(discord.py)
0
在消息删除消息 Discord.py
0
如何使 discord.py 机器人私人/直接消息不是作者的人?
0
(Discord.py) 如何获取整个嵌入内容?
0
Discord bot 尽管获得了许可,但不能提及所有人
0
Discord.py discord.NotFound 异常
0
