QWidgetAction:用户完成输入后如何使菜单消失(QWidgetAction : how to make the menu disappear after the user completes

编程入门 行业动态 更新时间:2024-10-26 16:32:14
QWidgetAction:用户完成输入后如何使菜单消失(QWidgetAction : how to make the menu disappear after the user completes his input)

在我的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

本文发布于:2023-07-29 20:45:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1319601.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:菜单   用户   menu   QWidgetAction   completes

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!