0

Cancel-button is in a dialog and connects to QDialog::reject().

So if I click Cancel-button, the dialog will emit signal-rejected().

Then I connect another checkable-button with the QDialog::rejected(). Once checkable-button receives the rejected(), it becomes un-checkable.

The supposed behavior is the checkable-button becomes un-checkable and the Dialog disappears. However, the real situation is that Dialog doesn't disappear.

Could you tell me what's wrong and how to fix this problem? Thank you very much....

Louis Langholtz
  • 2,913
  • 3
  • 17
  • 40
Nick.Rhan
  • 167
  • 2
  • 7
  • Show your code to understand yourself better to see what is causing the problem. – eyllanesc Dec 07 '17 at 01:40
  • Thank you very for your comment. The problem is really tricky, and I have solved. I set the checkable-button as toggled(bool). As this signal indicates, once its status changes, the slot will reflect, no matter when the bool value is true or false. This is the very key of the problem. Then I replaced toggled() with clicked(), everything done well. – Nick.Rhan Dec 07 '17 at 03:25
  • You don't have to emit `rejected()` signal explicitly. It will be emitted by the dialog when you call `QDialog::reject()` function to close it. Emitting the signal doesn't close the dialog. – vahancho Dec 07 '17 at 07:28
  • You are right. In this case, I only connected the rejected() with the my self-defined slots. But the weired behavior really confused me. Luckily, I have found the where the problem locates. – Nick.Rhan Dec 11 '17 at 04:45

0 Answers0