Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add QWidgetAction to QMenu through qtcreator/qtdesigner

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?

like image 237
Ilya Kobelevskiy Avatar asked Feb 07 '14 16:02

Ilya Kobelevskiy


1 Answers

Unfortunately that's not possible.

like image 165
Aleksandar Avatar answered Nov 15 '22 17:11

Aleksandar