How to disable a button in the slot function?
-
Thank You.It works fine so far it is concerned with button1.When I use button2 I want rest of them to be inactive/disabled.But writing the same code repeatedly by making changes for button that is out of group is complicated.
Well I tried with window modality as you have mentioned but still could not get the required result.
Is it possible to check for any active window(by using isActiveWindow) before I click on a button?Thank You
-
So, simply disable all buttons like I show above, and re-enable the one button you like to keep enabled?
@
#include <QApplication>void on_button1_clicked()
{
emit enableButton(false);
button1->setEnabled(true);
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
//do other things that may take serveral secondsemit enableButton(true);
}void on_button2_clicked()
{
emit enableButton(false);
button2->setEnabled(true);
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
//do something else that may also take serveral secondsemit enableButton(true);
}
@There are other solutions, of course.
I don't understand where you're going with your last question. What do you mean that you would like to check what the active window is (what do you mean by that, anyway?) when a button is clicked? That would obviously be the window that button is on then, would it not?