在我的QMenuBar中,我有几个菜单。
其中一个菜单中有一个QWidgetAction。
它显示正常,但问题是,一旦用户完成输入,我希望菜单消失(这是经典QAction的正常行为)。
但是,我不知道该怎么做。 在我的QWidgetAction中,用户在完成时会按下一个按钮; 因此,我可以绑定到此按钮的clicked()信号。
在插槽中,我尝试将setFocus()设置为菜单外的元素,但菜单仍然不会消失。
当用户完成与QWidgetAction的交互时,如何告诉菜单关闭?
谢谢
In my QMenuBar, I have several menus.
One of those menus has a QWidgetAction in it.
It shows up fine, but the problem is that once the user completes his input, I want the menu to disappear (as is the normal behavior for a classical QAction).
However, I am not sure on how to do that. In my QWidgetAction, there is a button the user presses when he is done; I can therefore bind to this button's clicked() signal.
In the slot, I tried to setFocus() an element outside the menu but the menu still doesn't disappear.
How to tell the menu to close itself when my users finish interacting with the QWidgetAction?
Thanks
最满意答案
QMenu继承了QWidget,因此调用yourMenu-> hide()应该可以完成工作。
希望这可以帮助。
QMenu inherits QWidget, so calling yourMenu->hide() should do the work.
Hope this helps.
更多推荐
QWidgetAction,菜单,In,电脑培训,计算机培训,IT培训"/> <meta name="descripti
发布评论