QMenu
函数介绍
1.void setContextMenuPolicy(Qt::ContextMenuPolicy policy)
This enum type defines the various policies a widget can have with respect to showing a context menu.
Constant | Value | Description |
---|---|---|
Qt::NoContextMenu | 0 | the widget does not feature a context menu, context menu handling is deferred to the widget’s 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(). |
Qt::DefaultContextMenu | 1 | the widget’s QWidget::contextMenuEvent() handler is called. |
Qt::ActionsContextMenu | 2 | the widget displays its QWidget::actions() as context menu. |
Qt::CustomContextMenu | 3 | the widget emits the QWidget::customContextMenuRequested() signal. |
示例
示例1:创建上下文菜单(createContextMenu)
1 | // .h |
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Vinda's Blog!
评论