QWidgetAction 在触发器()之后保持可见
我有一个 QWidgetAction,它包含一个由 QLineEdit 和 QPushButton 组成的 QWidget。一旦用户按下按钮,QWidgetAction 就会调用触发槽。
现在我有一个 QMenu,我用 exec 激活它。问题是,即使调用了触发器(我也将其连接到打印函数以进行检查),菜单也不会关闭。
定期的 QActions 效果很好。
知道为什么吗?
I have a a QWidgetAction which holds a QWidget composed of a QLineEdit and a QPushButton. Once the user press the button the QWidgetAction call the trigger slot.
Now I have a QMenu which I activate with exec. The problem is that even though trigger is called (I've connected it to a print function as well to check) the menu won't close.
Regular QActions works well.
Any idea why?
P.S. Googling this issue I came across people with the same problem, but no solutions.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
多年的问题,但我仍然有答案,希望它对任何人有帮助!
我将描述我的完整解决方案,它不仅隐藏菜单,还管理视觉表示。
QWidgetAction 子类:MyClass.h
QWidgetAction 子类 MyClass.cpp
最后要在菜单中插入 QWidgetAction,请在代码中添加以下内容:
Years old question, but still I have an answer, hope it helps anybody!
I will describe my complete solution which not only hides the menu but also manages the visual representation.
QWidgetAction subclass: MyClass.h
QWidgetAction subclass MyClass.cpp
Finally to insert the QWidgetAction in a menu, in your code add the following: