QContextMenuEvent Class Reference

[ QtGui module]

The QContextMenuEvent class contains parameters that describe a context menu event. 更多...

继承 QInputEvent .

类型

方法


详细描述

The QContextMenuEvent class contains parameters that describe a context menu event.

Context menu events are sent to widgets when a user performs an action associated with opening a context menu. The actions required to open context menus vary between platforms; for example, on Windows, pressing the menu button or clicking the right mouse button will cause this event to be sent.

当此事件发生时,通常展示 QMenu with a context menu, if this is relevant to the context.

Context menu events contain a special accept flag that indicates whether the receiver accepted the event. If the event handler does not accept the event then, if possible, whatever triggered the event will be handled as a regular input event.


类型文档编制

QContextMenuEvent.Reason

此枚举描述事件为什么被发送的原因。

常量 描述
QContextMenuEvent.Mouse 0 The mouse caused the event to be sent. Normally this means the right mouse button was clicked, but this is platform dependent.
QContextMenuEvent.Keyboard 1 The keyboard caused this event to be sent. On Windows, this means the menu button was pressed.
QContextMenuEvent.Other 2 The event was sent by some other means (i.e. not by the mouse or keyboard).

方法文档编制

QContextMenuEvent.__init__ ( self , Reason   reason , QPoint   pos , QPoint   globalPos , Qt.KeyboardModifiers   modifiers )

Constructs a context menu event object with the accept parameter flag set to false.

reason 参数必须是 QContextMenuEvent.Mouse or QContextMenuEvent.Keyboard .

pos parameter specifies the mouse position relative to the receiving widget. globalPos is the mouse position in absolute coordinates. The modifiers holds the keyboard modifiers.

QContextMenuEvent.__init__ ( self , Reason   reason , QPoint   pos , QPoint   globalPos )

Constructs a context menu event object with the accept parameter flag set to false.

reason 参数必须是 QContextMenuEvent.Mouse or QContextMenuEvent.Keyboard .

pos parameter specifies the mouse position relative to the receiving widget. globalPos is the mouse position in absolute coordinates.

QContextMenuEvent.__init__ ( self , Reason   reason , QPoint   pos )

Constructs a context menu event object with the accept parameter flag set to false.

reason 参数必须是 QContextMenuEvent.Mouse or QContextMenuEvent.Keyboard .

pos parameter specifies the mouse position relative to the receiving widget.

globalPos () is initialized to QCursor.pos (), which may not be appropriate. Use the other constructor to specify the global position explicitly.

QContextMenuEvent.__init__ ( self , QContextMenuEvent )

QPoint QContextMenuEvent.globalPos ( self )

Returns the global position of the mouse pointer at the time of the event.

另请参阅 x (), y (),和 pos ().

int QContextMenuEvent.globalX ( self )

Returns the global x position of the mouse pointer at the time of the event.

另请参阅 globalY () 和 globalPos ().

int QContextMenuEvent.globalY ( self )

Returns the global y position of the mouse pointer at the time of the event.

另请参阅 globalX () 和 globalPos ().

QPoint QContextMenuEvent.pos ( self )

Returns the position of the mouse pointer relative to the widget that received the event.

另请参阅 x (), y (),和 globalPos ().

Reason QContextMenuEvent.reason ( self )

Returns the reason for this context event.

int QContextMenuEvent.x ( self )

Returns the x position of the mouse pointer, relative to the widget that received the event.

另请参阅 y () 和 pos ().

int QContextMenuEvent.y ( self )

Returns the y position of the mouse pointer, relative to the widget that received the event.

另请参阅 x () 和 pos ().