Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
是否可以响应单击顶级菜单项?例如,参考下图,点击“帮助”菜单项时是否可以运行代码?
如果是这样,我该怎么做?
谢谢你。
您可以使用QMenu::aboutToShow()信号并执行以下操作:
QMenu::aboutToShow()
connect(helpMenu, SIGNAL(aboutToShow()), this, SLOT(onHelpMenuClicked()));
wherehelpMenu是指向您的帮助菜单的指针,并且onHelpMenuClicked()是一旦您单击Help菜单就会被调用的插槽。
helpMenu
onHelpMenuClicked()
Help