[Qt-interest] Why I can't see the Menu on my Widget?
Oliver Demetz
forenbeitraege at oliverdemetz.de
Tue Jun 9 09:44:46 CEST 2009
Also,
you can just use the layout of your widget and call QLayout::setMenuBar
to accieve what you want.
Regards,
Oliver
Alessandro Portale schrieb:
> Hi,
>
> in order to get an application menu, You need to subclass your TopLevel
> Ui from QMainWindow. In the constructur, you can call menuBar() in order
> to obtain a QMenuBar pointer, and to that you can add the actions.
>
> http://doc.qtsoftware.com/latest/qmainwindow.html#menuBar
>
> Hope that helps,
> Alessandro
>
> Kermit Mei schrieb:
>> Hello, I create a Menu in the constructor of my MainWidget class, The
>> code is like this:
>>
>> MainWidget::MainWidget(QWidget *parent)
>> : QWidget(parent)
>> {
>> setWindowFlags(Qt::CustomizeWindowHint);
>> setGeometry(0,0,320,224);
>> setMinimumSize(320,224);
>> setMaximumSize(320,224);
>>
>> loadActions("mainmenu");
>> confBar = new QMenuBar();
>> confMenu =
>> confBar->addMenu(QPixmap(":/newPrefix/images/config.png"),"test");
>>
>> confBar->setGeometry(0,192,32,32);
>>
>> foreach(QAction *act,confActions)
>> confMenu->addAction(act);
>> }
>>
>> But when I run it, I can't see the Menu, there's just one empty widget.
>> Why?
>>
>> Thanks
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
More information about the Qt-interest-old
mailing list