Qt - 弹出菜单 [英] Qt - Pop up menu

查看:34
本文介绍了Qt - 弹出菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将标签作为图像(图标)添加到 Qt 中的小部件.我想在用户单击(左键或右键单击)标签时显示一个弹出菜单.我怎样才能做到这一点?请帮忙...

I have added a label as an image(icon) to a widget in Qt. I want to display a pop-up menu when the user clicks (left or right click) on the label. How can I achieve this ? Please help...

推荐答案

您需要设置小部件的 ContextMenuPolicy,然后将 customContextMenuRequested 事件连接到一些将显示菜单的插槽.

You'll want to set the ContextMenuPolicy of the widget, then connect the customContextMenuRequested event to some slot which will display the menu.

请参阅:Qt 和上下文菜单

这篇关于Qt - 弹出菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆