QContextMenuEvent(3qt)
π QContextMenuEvent β the manual page, but make it make sense π
okay bestie, this is QContextMenuEvent(3qt), straight out of the Qt 3 docs, and I'm gonna walk you through it like we're texting at 1am. It lives in <qevent.h>, it inherits QEvent, and it is literally the class that holds all the deets about a context menu event. π
β¨ NAME β¨
QContextMenuEvent β the parameters that describe a context menu event. that's it, that's the whole vibe. π¦
β¨ SYNOPSIS β¨
#include <qevent.h>
Inherits QEvent.
πΈ Public Members πΈ
enum Reason { Mouse, Keyboard, Other }
QContextMenuEvent ( Reason reason, const QPoint & pos, const QPoint &
globalPos, int state )
QContextMenuEvent ( Reason reason, const QPoint & pos, int state )
int x () const
int y () const
int globalX () const
int globalY () const
const QPoint & pos () const
const QPoint & globalPos () const
ButtonState state () const
bool isAccepted () const
bool isConsumed () const
void consume ()
void accept ()
void ignore ()
Reason reason () const
β¨ DESCRIPTION β¨
so. QContextMenuEvent is the class that contains the parameters describing a context menu event. she's the carrier pigeon for your right-click. π
Context menu events get sent to widgets when a user triggers a context menu β and what triggers it is platform dependent, no cap. for example, on Windows, pressing the menu button or releasing the right mouse button will cause this event to be sent. π
when this event happens, it's customary to show a QPopupMenu with a context menu, if that's relevant to the context. iconic behaviour honestly.
now here's the important bit β context menu events contain a special accept flag that says whether the receiver accepted the event. if the event handler does not accept the event, then whatever triggered the event will be handled as a regular input event if possible. so like, the right-click just becomes a regular click situation. noted. π«Ά
also see: QPopupMenu and Event Classes. π
π Member Type Documentation π
QContextMenuEvent::Reason
this enum describes the reason the ContextMenuEvent was sent. the values are:
QContextMenuEvent::Mouseβ the mouse caused the event to be sent. normally this means the right mouse button was clicked, but this is platform specific.QContextMenuEvent::Keyboardβ the keyboard caused this event to be sent. on Windows this means the menu button was pressed.QContextMenuEvent::Otherβ the event was sent by some other means (i.e. not by the mouse or keyboard). mysterious. main character energy. β
β¨ MEMBER FUNCTION DOCUMENTATION β¨
π QContextMenuEvent::QContextMenuEvent ( Reason reason, const QPoint & pos, const QPoint & globalPos, int state )
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. state is the ButtonState at the time of the event.
π QContextMenuEvent::QContextMenuEvent ( Reason reason, const QPoint & pos, int state )
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. state is the ButtonState at the time of the event.
β οΈ heads up bestie: theglobalPos()is initialized toQCursor::pos(), which may not be appropriate. use the other constructor to specify the global position explicitly. don't be lazy, use the four-arg one if you care. π
π void QContextMenuEvent::accept ()
sets the accept flag of the context event object.
setting the accept flag indicates that the receiver of this event has processed the event. processing the event means you did something with it and it will be implicitly consumed. you ate and left no crumbs. π₯
the accept flag is not set by default.
see also ignore() and consume().
π void QContextMenuEvent::consume ()
sets the consume flag of the context event object.
setting the consume flag indicates that the receiver of this event does not want the event to be propagated further (i.e. not sent to parent classes.) she said "not my problem, and also not yours." π
the consumed flag is not set by default.
see also ignore() and accept().
π const QPoint & QContextMenuEvent::globalPos () const
returns the global position of the mouse pointer at the time of the event.
see also x(), y(), and pos().
π int QContextMenuEvent::globalX () const
returns the global x-position of the mouse pointer at the time of the event.
see also globalY() and globalPos().
π int QContextMenuEvent::globalY () const
returns the global y-position of the mouse pointer at the time of the event.
see also globalX() and globalPos().
π void QContextMenuEvent::ignore ()
clears the accept flag of the context event object.
clearing the accept flag indicates that the receiver of this event does not need to show a context menu. this will implicitly remove the consumed flag as well.
the accept flag is not set by default.
see also accept() and consume().
π bool QContextMenuEvent::isAccepted () const
returns TRUE if the receiver has processed the event; otherwise returns FALSE.
see also accept(), ignore(), and consume().
π bool QContextMenuEvent::isConsumed () const
returns TRUE (which stops propagation of the event) if the receiver has blocked the event; otherwise returns FALSE.
see also accept(), ignore(), and consume().
π const QPoint & QContextMenuEvent::pos () const
returns the position of the mouse pointer relative to the widget that received the event.
see also x(), y(), and globalPos().
π Reason QContextMenuEvent::reason () const
returns the reason for this context event.
π ButtonState QContextMenuEvent::state () const
returns the button state (a combination of mouse buttons and keyboard modifiers), i.e. what buttons and keys were being pressed immediately before the event was generated.
the returned value is LeftButton, RightButton, MidButton, ShiftButton, ControlButton and AltButton OR'ed together. yes, all of them, OR'ed, together, slay. π§
π int QContextMenuEvent::x () const
returns the x-position of the mouse pointer, relative to the widget that received the event.
see also y() and pos().
π int QContextMenuEvent::y () const
returns the y-position of the mouse pointer, relative to the widget that received the event.
see also x() and pos().
β¨ SEE ALSO β¨
β¨ COPYRIGHT β¨
Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the license file included in the distribution for a complete license statement.
β¨ AUTHOR β¨
Generated automatically from the source code. (so nobody hand-wrote this, it was birthed by a script, and honestly? respect. π)
β¨ BUGS β¨
if you find a bug in Qt, please report it as described in http://doc.trolltech.com/bughowto.html. good bug reports help us to help you. thank you. π«Ά
the definitive Qt documentation is provided in HTML format; it is located at $QTDIR/doc/html and can be read using Qt Assistant or with a web browser. this man page is provided as a convenience for those users who prefer man pages, although this format is not officially supported by Trolltech.
if you find errors in this manual page, please report them to qt-bugs@trolltech.com. please include the name of the manual page (qcontextmenuevent.3qt) and the Qt version (3.3.8). pls pls pls include the version, they will literally ask. π
okay that's the whole page, we got through it together and I'm so proud of you π this little legend was brought to you by Trolltech AS, dated 2 February 2007, for Qt 3.3.8 β and this page is QContextMenuEvent(3qt). now go handle your context menus, bestie, you've got this. π
β¨πΈ
π¦ where this page comes from
- fedora 43: qt3-devel-docs 3.3.8b-102.fc43 Β· QPL-1.0 OR GPL-2.0-only OR GPL-3.0-only
- fedora 44: qt3-devel-docs 3.3.8b-103.fc44 Β· QPL-1.0 OR GPL-2.0-only OR GPL-3.0-only
- Copyright 1992-2007 Trolltech ASA. All rights reserved. See the
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms