Qt ContextMenu

QTableWidget中设置右键点击事件:

tableWidget->setContextMenuPolicy(Qt::CustomContextMenu);
 connect(tableWidget,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(rightMouseClicked()));
contextMenuPolicy:
This property holds how the widget shows a context menu.
这个属性用来设置widget如何显示一个context menu

enum:

Constant                Value   Description
Qt::NoContextMenu          0    the widget does not feature a context menu, context menu    
                                handling is deferred to the widget's parent.
                                widget中没有出现context  menu,context menu的处理将会顺延
                                到parent。

Qt::PreventContextMenu     4    the widget does not feature a context menu, and in  
                                contrast to NoContextMenu, the handling is not deferred         
                                to the widget's parent. This means that all right mouse 
                                button  events are guaranteed to be delivered to the 
                                widget itself through QWidget::mousePressEvent(), and 
                                QWidget::mouseReleaseEvent().
                                部件没有出现context menu。与NoContextMenu相比,处理不会顺延
                                到parent。意味着所有的鼠标右击事件都将交给QWidget::mousePressEvent(), 
                                and QWidget::mouseReleaseEvent()处理

Qt::DefaultContextMenu    1     the widget's QWidget::contextMenuEvent() handler is
 called.
                                 (默认)ContextMenuEvent 请求处理相应


Qt::ActionsContextMenu    2     the widget displays its QWidget::actions() as context menu.
                                widget显示它的QWidget::actions()作为context menu
Qt::CustomContextMenu     3     the widget emits the QWidget::customContextMenuRequested() signal.
                                //widget发送QWidget::customContextMenuRequested()信号。
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值