Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QCheckBox change state without triggering stateChanged
midnightdim last edited by midnightdim
I'm stuck with the following problem.
I have a QCheckBox and a list of items in a table. I'm recording checked/unchecked state of each item to the database when user selects and item and checks/unchecks the checkbox.
update_db()that updates the item state in the database.
I also need to update the state of the checkbox to show the current state of the item when user selects the item in the table.
To do this I call
The problem is that when I call
stateChanged()which in turn triggers
update_db()which is an unnecessary call.
Is it possible to call
setCheckState()) without triggering
Or is it possible to identify if
stateChanged()was triggered by the user action or by the code?
A possible solution would be to connect to
clicked()instead - it doesn't trigger
stateChanged(). Is this the only solution?
You can use QSignalBlocker.
midnightdim last edited by
@SGaist Thanks! For now I switched to
clicked()which seems to be fine, but checked
QSignalBlockerand it works too, good to know it exists.
I'm new to Qt and it's really impressive how thought out to the details it is! And what's more important there are gurus who share their knowledge and respond quicker than tech support of most of the software dev companies :-) Thanks again!