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 ?
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With