Reputation: 38265
Say upon launching the Qt application, is there a way to display a grayed out main window, and disable all the widgets (buttons/checkboxes/etc) - not able to click. Once the user open a file or do some init procedure, the main window becomes non-grayed out and enable all widgets. Is this something possible in Qt?
Upvotes: 6
Views: 14198
Reputation: 2718
Yes. Just call QWidget::setEnabled(false)
to disable a window/widget, and QWidget::setEnabled(true)
to enable it.
By the way, the Qt documentation is very comprehensive. Just search there, and you should easily find answers to many questions.
Upvotes: 9
Reputation: 11
Add a gray overlay label, those size equals your main window. Of course, don't forget the setEnabled(false)
.
Upvotes: 0
Reputation: 1523
In my software, before creating a new widget, I disabled all the buttons in the parent window with this:
void MainWindow::disableAllButtons(bool toBeEnabled){
QList<QPushButton *> buttonsList = this->findChildren<QPushButton *>();
for (int i = 0; i < buttonsList.count(); i++){
buttonsList.at(i)->setEnabled(toBeEnabled);
}
}
Of course I had to call this again, when closing the widget, to re-enable the buttons. Guess it can be adapted to disable/enable other kind of widgets. It works on QT 4.8.
Upvotes: 0