将插槽添加到自动创建的菜单项
我有一个名为“保存”的现有菜单,我想在其中添加两个菜单,“保存新菜单”和“保存编辑”。
QMenu *menu = new QMenu(this);
menu->addAction("Save New");//void saveNew()
menu->addAction("Save Edits");//void saveEdits()
ui.saveButton->setMenu(menu);
我已经查找了合适的功能并找到了这个,但我需要帮助来实现它。
QAction * QMenu::addAction ( const QString & text, const QObject * receiver, const char * member, const QKeySequence & shortcut = 0 )
我该怎么办?
I have an existing menu called save and in it i want to add two menus,Save New and Save Edits.
QMenu *menu = new QMenu(this);
menu->addAction("Save New");//void saveNew()
menu->addAction("Save Edits");//void saveEdits()
ui.saveButton->setMenu(menu);
I have looked up for a suitable function and found this but i need help implemening it.
QAction * QMenu::addAction ( const QString & text, const QObject * receiver, const char * member, const QKeySequence & shortcut = 0 )
How can i do it?.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用与
connect
调用中使用的相同参数:如果菜单是在设计器中创建的,您可以连接同时创建的相应操作:
或使用信号/槽编辑器直接连接设计器内部的操作。
With the same parameters you would use in that
connect
call:If the menu was created in the designer, you can connect the corresponding actions that were created at the same time:
or use the signal/slot editor to connect directly the actions from within the designer.