QAction *action = new QAction("Save", this); if (text.isEmpty()) { action->setDisabled(true); } else { action->setDisabled(false); }
QAction *action = new QAction("Open", this); action->setDisabled(true);In this example, the "Open" action is disabled by default and needs to be enabled by another action. The QAction setDisabled function is part of the Qt GUI library.