Hi,
I did some coding accordingly. The menu is substituted successfully but this works only after the new menu instance is added next to the default menu. I can't able to remove the default one from menu bar.
Here I am placing the code and image of the app. Please suggest me how can I overcome this problem.
calculateHelper
::calculateHelper(QWidget *parent
) : ui(new Ui::calculateHelper)
{
ui->setupUi(this);
setMenuBar(b);
page_1
= new QMenu(tr
("&Main"),
this);
page_2
= new QMenu(tr
("&Edit"),
this);
page_3
= new QMenu(tr
("&Reminder"),
this);
optionsmenu();
ui->stackedWidget->setCurrentIndex(0);
b->addMenu(page_1);
}
void calculateHelper::optionsMenu()
{
created the actions for all the menus
}
void calculateHelper::indexChange(int i)
{
switch(i)
{
case 0: b->clear();
page_1->clear();
b->addMenu(page_1);
break;
case 1: b->clear();
b->addMenu(page_2);
break;
case 2:b->clear();
b->addMenu(page_3);
default: break;
}
}
calculateHelper::calculateHelper(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::calculateHelper)
{
ui->setupUi(this);
b = new QMenuBar(this);
setMenuBar(b);
page_1 = new QMenu(tr("&Main"),this);
page_2 = new QMenu(tr("&Edit"),this);
page_3 = new QMenu(tr("&Reminder"),this);
optionsmenu();
ui->stackedWidget->setCurrentIndex(0);
b->addMenu(page_1);
}
void calculateHelper::optionsMenu()
{
created the actions for all the menus
}
void calculateHelper::indexChange(int i)
{
switch(i)
{
case 0: b->clear();
page_1->clear();
b->addMenu(page_1);
break;
case 1: b->clear();
b->addMenu(page_2);
break;
case 2:b->clear();
b->addMenu(page_3);
default: break;
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks