You can listen to signals QComboBox::activated(int index)and QComboBox::currentIndexChanged(int index).
If the user changes the value of the signals will be rejected QComboBox::activated(int index)and QComboBox::currentIndexChanged(int index).
If the value changes programmatically, only a signal will be emitted QComboBox::currentIndexChanged(int index). Thus, the first signal means: "The user has changed the index to this value."
Example:
int main(int argc, char* argv[]) {
QComboBox* combo = new QComboBox;
QObject::connect(combo, &QComboBox::activated, [&](int index) {
});
}
I hope this helps!
source
share