1

对于 stateChanged 信号,我的 QT Slot 函数中有以下情况:

void ui::myslot(int state) {
  ...
  if (condition) {
    checkbox->setChecked(true);
  }
  ...
}

如果我的复选框已经被选中,当我尝试取消选中它时,如果条件满足,复选框将再次被选中。但是,当我再次尝试取消选中它并且条件仍然为真时,它只是变为未选中,没有发出任何信号。即,上面的函数甚至没有被调用......

知道这里会发生什么吗?

非常感谢!:)

4

1 回答 1

0

Did you try to create a temporary slot, connect it with the stateChanged() signal? For example:

void onStateChanged(int state);

You can define the slot as:

void onStateChanged(int state)
{
    qDebug() << "State changed.";
}

Don't forget to include header in the .cpp file. Then connect the slot with the signal and launch the application. If you see "State changed." in the standard output and the execucution reaches the slot, then the signal is emitted properly.

于 2017-07-23T15:59:53.590 回答