PDA

View Full Version : Fog with QMenu



Blitzor DDD
28th August 2016, 10:23
Hi there!

I am trying to set Menu on Widget.


void Widget::set_menu(QMenuBar * menuBar)
{
qDebug()<<"set menu"<<endl;
QMenu* pmnu = new QMenu("&Menu");
menuBar->addMenu(pmnu);
}

and call this function in constructor:


Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)

{
ui->setupUi(this);
set_frame();
set_menu(/*????*/);
}

What should I call as an argument in set_menu()?
And am I on the right way?

anda_skoa
28th August 2016, 16:46
Well, obviously you need to pass a pointer to a QMenuBar, that is what your function expects.
Have you created one?

The easiest way to get a menu bar is to derive from QMainWindow though.

Cheers,
_