ich möchte Menüpunkte bei Bedarf deaktivieren.
Als erstes erzeuge ich mir die entsprechenden Actions:
Code: Alles auswählen
startAllViewsAct = new QAction(tr("Alle Views starten"), this);
startAllViewsAct->setStatusTip(tr("Startet die Logging-Funktion auf allen Views"));
connect(startAllViewsAct, SIGNAL(triggered()), this, SLOT(startAllViews));
stopAllViewsAct = new QAction (tr("Alle Views stoppen"), this);
stopAllViewsAct->setStatusTip(tr("Stoppt die Logging-Funktion auf allen Views"));
stopAllViewsAct->setEnabled(false);
connect(stopAllViewsAct, SIGNAL(triggered()), this, SLOT(stopAllViews));
Anschließend erzeuge ich das Menü aus meinen verschiedenen Acts:
Code: Alles auswählen
fileMenu = menuBar()->addMenu(tr("&Datei"));
fileMenu->addAction(saveLogAct);
fileMenu->addAction(exitAct);
functionMenu = menuBar()->addMenu(tr("F&unktion"));
functionMenu->addAction(startAllViewsAct);
functionMenu->addAction(stopAllViewsAct);
Nun noch die betreffenden Slots implementieren:
Code: Alles auswählen
void fmbMonitor::startAllViews()
{
startAllViewsAct->setEnabled(false);
stopAllViewsAct->setEnabled(true);
}
void fmbMonitor::stopAllViews()
{
stopAllViewsAct->setEnabled(false);
startAllViewsAct->setEnabled(true);
}
Kann mir jemand einen Tipp geben?
mfg
Christian