vinaycool
16th July 2018, 17:31
I have an Widget class as a QtPlugin. In my main application i want to load this widget and add to menubar as toggledaction, so that later if i close the widget i can open it via the Menu bar. How can this be achieved.
As this is not a docketwidget i cannot use the following:
ui->menuPlugins->addAction(dockedWidget->toggleViewAction());
I have tried something like this:
void MainWindow::addToPluginsMenu(QWidget *const widget) {
ui->menuPlugins->setEnabled(true);
QWidgetAction *ac = new QWidgetAction(this);
ui->menuPlugins->addAction(ac);
}
An action is added but it is empty and cannot be toggled. Could anyone provide me a solution?
Thank you
As this is not a docketwidget i cannot use the following:
ui->menuPlugins->addAction(dockedWidget->toggleViewAction());
I have tried something like this:
void MainWindow::addToPluginsMenu(QWidget *const widget) {
ui->menuPlugins->setEnabled(true);
QWidgetAction *ac = new QWidgetAction(this);
ui->menuPlugins->addAction(ac);
}
An action is added but it is empty and cannot be toggled. Could anyone provide me a solution?
Thank you