Question

I am wondering if there is a way to add QWidgetAction to QMainwindow->QMenuBar->QMenu using either qtcreator or qtdesigner.

I can add a widget through the code like that:

//ui->myMenu is QMenu in QMenuBar of QMainWindow
QWidgetAction *act = new QWidgetAction(ui->myMenu);  
QLineEdit* edt = new QLineEdit("I am Line edit",ui->myMenu);
//setup edt ...
act->setDefaultWidget(edt);
ui->myMenu->addAction(act);

It compiles and works as expected.

However, I cannot achieve same behavior using ui designer - it only lets me add QAction and QMenu classes as parts of QMenuBar/QMenu, and does not give option to promote QAction to QWidgetAction. Is there a way to add QWidgetAction and a widget associated with it through designer to have them as part of Ui namespace and their properties editable through ui editor?

Was it helpful?

Solution

Unfortunately that's not possible.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top