CopperSpice API  1.7.2
QContextMenuEvent Class Reference

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

Inheritance diagram for QContextMenuEvent:
QInputEvent QEvent

Public Types

enum  Reason
 
- Public Types inherited from QEvent
enum  Type
 

Public Methods

 QContextMenuEvent (Reason reason, const QPoint &pos)
 
 QContextMenuEvent (Reason reason, const QPoint &pos, const QPoint &globalPos)
 
 QContextMenuEvent (Reason reason, const QPoint &pos, const QPoint &globalPos, Qt::KeyboardModifiers modifiers)
 
const QPointglobalPos () const
 
int globalX () const
 
int globalY () const
 
const QPointpos () const
 
Reason reason () const
 
int x () const
 
int y () const
 
- Public Methods inherited from QInputEvent
Qt::KeyboardModifiers modifiers () const
 
void setModifiers (Qt::KeyboardModifiers amodifiers)
 
void setTimestamp (ulong atimestamp)
 
ulong timestamp () const
 
- Public Methods inherited from QEvent
 QEvent (const QEvent &other)
 
 QEvent (Type type)
 
virtual ~QEvent ()
 
void accept ()
 
void ignore ()
 
bool isAccepted () const
 
QEvent & operator= (const QEvent &other)
 
void setAccepted (bool accepted)
 
bool spontaneous () const
 
Type type () const
 

Additional Inherited Members

- Static Public Methods inherited from QEvent
static int registerEventType (int hint=-1)
 

Detailed Description

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.

When this event occurs it is customary to show a 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.

See also
x(), y(), pos()

Member Enumeration Documentation

This enum describes the reason why the event was sent.

ConstantValueDescription
QContextMenuEvent::Mouse0The mouse caused the event to be sent. Normally this means the right mouse button was clicked, but this is platform dependent.
QContextMenuEvent::Keyboard1The keyboard caused this event to be sent. On Windows, this means the menu button was pressed.
QContextMenuEvent::Other2The event was sent by some other means (i.e. not by the mouse or keyboard).

Constructor & Destructor Documentation

QContextMenuEvent::QContextMenuEvent ( Reason  reason,
const QPoint pos,
const QPoint globalPos,
Qt::KeyboardModifiers  modifiers 
)

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

The reason parameter must be QContextMenuEvent::Mouse or QContextMenuEvent::Keyboard.

The 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::QContextMenuEvent ( Reason  reason,
const QPoint pos,
const QPoint globalPos 
)

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

The reason parameter must be QContextMenuEvent::Mouse or QContextMenuEvent::Keyboard.

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

QContextMenuEvent::QContextMenuEvent ( Reason  reason,
const QPoint pos 
)

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

The reason parameter must be QContextMenuEvent::Mouse or QContextMenuEvent::Keyboard.

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

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

Method Documentation

const QPoint & QContextMenuEvent::globalPos ( ) const
inline

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

See also
x(), y(), pos()
int QContextMenuEvent::globalX ( ) const
inline

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

See also
globalY(), globalPos()
int QContextMenuEvent::globalY ( ) const
inline

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

See also
globalX(), globalPos()
const QPoint & QContextMenuEvent::pos ( ) const
inline

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

See also
x(), y(), globalPos()
Reason QContextMenuEvent::reason ( ) const
inline

Returns the reason for this context event.

int QContextMenuEvent::x ( ) const
inline

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

See also
y(), pos()
int QContextMenuEvent::y ( ) const
inline

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

See also
x(), pos()