PyQt组合框更改标签的值

PyQt combo box change value of a label(PyQt组合框更改标签的值)
本文介绍了PyQt组合框更改标签的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我正在使用 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

这篇关于PyQt组合框更改标签的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

groupby multiple coords along a single dimension in xarray(在xarray中按单个维度的多个坐标分组)
Group by and Sum in Pandas without losing columns(Pandas中的GROUP BY AND SUM不丢失列)
Group by + New Column + Grab value former row based on conditionals(GROUP BY+新列+基于条件的前一行抓取值)
Groupby and interpolate in Pandas(PANDA中的Groupby算法和插值算法)
Pandas - Group Rows based on a column and replace NaN with non-null values(PANAS-基于列对行进行分组,并将NaN替换为非空值)
Grouping pandas DataFrame by 10 minute intervals(按10分钟间隔对 pandas 数据帧进行分组)