I am developing one application in which I have to show a dialog when I click on dialog button (which is checkable) from mainwindow.
The dialog is non modal.
Now There are 2 ways I have to close this dialog when mainwindow gets focus or when I press that dialog button again.
When mainwindow gets focus this dialog closes properly.

But the problem occurs when I press that dialog button from mainwindow. Because it causes mainwindow to get focus first so the dialog will close.
But after that it will also call the button_clicked(bool) slot which will again open that dialog which is not expected.

I want to remove this behavior. Please help.

Thanks in advance,