Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PyQt combo box change value of a label [closed]

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 ?

like image 699
Mario Campos Avatar asked Jun 22 '17 19:06

Mario Campos


1 Answers

If you mean the signal of combo box, when it's value changed, you can use

QComboBox.currentTextChanged

or

QComboBox.currentIndexChanged

Everytime a combobox is changed by user, these signals will be triggered.

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

just

cb_1.currentTextChanged.connect(self.on_combobox_changed)

try to change the combobox and see what will happen

like image 56
milo Avatar answered Nov 14 '22 21:11

milo