在 Menu下面添加动作也可以,前提是把所有代码写完。在QT文档里面也是这么写,
在MENU下面有个函数
void QMenu::addAction ( QAction * action )
This is an overloaded member function, provided for convenience.
Appends the action action to the menu's list of actions.
这就这个意思。
你说的这方法在QACTION 下面也找到了
Once a QAction has been created it should be added to the relevant menu and toolbar, then connected to the slot which will perform the action. For example:
openAct = new QAction(QIcon(":/images/open.png"), tr("&Open..."), this);
openAct->setShortcuts(QKeySequence::Open);
openAct->setStatusTip(tr("Open an existing file"));
connect(openAct, SIGNAL(triggered()), this, SLOT(open()));
fileMenu->addAction(openAct);
fileToolBar->addAction(openAct);
We recommend that actions are created as children of the window they are used in. In most cases actions will be children of the application's main window.
不知道这怎么回事。
谢谢!