Prevent Firing Signals in Qt

前端 未结 8 962
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-14 14:07

We have a QCheckBox object, when user checks it or removes check we want to call a function so we connect our function to stateChanged ( int state )

8条回答
  •  死守一世寂寞
    2020-12-14 14:30

    Qt5.3 introduced the QSignalBlocker class that does exactly what needed in an exception safe way.

    if (something) {
       const QSignalBlocker blocker(someQObject);
       // no signals here
    }
    

提交回复
热议问题