Qt 4.8
|
The QMouseEvent class contains parameters that describe a mouse event. More...
#include <qevent.h>
Public Functions | |
Qt::MouseButton | button () const |
Returns the button that caused the event. More... | |
Qt::MouseButtons | buttons () const |
Returns the button state when the event was generated. More... | |
const QPoint & | globalPos () const |
Returns the global position of the mouse cursor at the time of the event. More... | |
int | globalX () const |
Returns the global x position of the mouse cursor at the time of the event. More... | |
int | globalY () const |
Returns the global y position of the mouse cursor at the time of the event. More... | |
bool | hasExtendedInfo () const |
const QPoint & | pos () const |
Returns the position of the mouse cursor, relative to the widget that received the event. More... | |
QPointF | posF () const |
Returns the position of the mouse cursor as a QPointF, relative to the widget that received the event. More... | |
QMouseEvent (Type type, const QPoint &pos, Qt::MouseButton button, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers) | |
Constructs a mouse event object. More... | |
QMouseEvent (Type type, const QPoint &pos, const QPoint &globalPos, Qt::MouseButton button, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers) | |
Constructs a mouse event object. More... | |
int | x () const |
Returns the x position of the mouse cursor, relative to the widget that received the event. More... | |
int | y () const |
Returns the y position of the mouse cursor, relative to the widget that received the event. More... | |
~QMouseEvent () | |
Public Functions inherited from QInputEvent | |
Qt::KeyboardModifiers | modifiers () const |
Returns the keyboard modifier flags that existed immediately before the event occurred. More... | |
QInputEvent (Type type, Qt::KeyboardModifiers modifiers=Qt::NoModifier) | |
void | setModifiers (Qt::KeyboardModifiers amodifiers) |
Sets the keyboard modifiers flags for this event. More... | |
~QInputEvent () | |
Public Functions inherited from QEvent | |
void | accept () |
Sets the accept flag of the event object, the equivalent of calling setAccepted(true). More... | |
void | ignore () |
Clears the accept flag parameter of the event object, the equivalent of calling setAccepted(false). More... | |
bool | isAccepted () const |
QEvent (Type type) | |
Contructs an event object of type type. More... | |
void | setAccepted (bool accepted) |
bool | spontaneous () const |
Returns true if the event originated outside the application (a system event); otherwise returns false. More... | |
Type | type () const |
Returns the event type. More... | |
virtual | ~QEvent () |
Destroys the event. More... | |
Static Public Functions | |
static QMouseEvent * | createExtendedMouseEvent (Type type, const QPointF &pos, const QPoint &globalPos, Qt::MouseButton button, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers) |
Static Public Functions inherited from QEvent | |
static int | registerEventType (int hint=-1) |
Registers and returns a custom event type. More... | |
Protected Variables | |
Qt::MouseButton | b |
QPoint | g |
Qt::MouseButtons | mouseState |
QPoint | p |
Protected Variables inherited from QInputEvent | |
Qt::KeyboardModifiers | modState |
Protected Variables inherited from QEvent | |
QEventPrivate * | d |
ushort | t |
The QMouseEvent class contains parameters that describe a mouse event.
Mouse events occur when a mouse button is pressed or released inside a widget, or when the mouse cursor is moved.
Mouse move events will occur only when a mouse button is pressed down, unless mouse tracking has been enabled with QWidget::setMouseTracking().
Qt automatically grabs the mouse when a mouse button is pressed inside a widget; the widget will continue to receive mouse events until the last mouse button is released.
A mouse event contains a special accept flag that indicates whether the receiver wants the event. You should call ignore() if the mouse event is not handled by your widget. A mouse event is propagated up the parent widget chain until a widget accepts it with accept(), or an event filter consumes it.
The state of the keyboard modifier keys can be found by calling the modifiers() function, inherited from QInputEvent.
The functions pos(), x(), and y() give the cursor position relative to the widget that receives the mouse event. If you move the widget as a result of the mouse event, use the global position returned by globalPos() to avoid a shaking motion.
The QWidget::setEnabled() function can be used to enable or disable mouse and keyboard events for a widget.
Reimplement the QWidget event handlers, QWidget::mousePressEvent(), QWidget::mouseReleaseEvent(), QWidget::mouseDoubleClickEvent(), and QWidget::mouseMoveEvent() to receive mouse events in your own widgets.
QMouseEvent::QMouseEvent | ( | Type | type, |
const QPoint & | position, | ||
Qt::MouseButton | button, | ||
Qt::MouseButtons | buttons, | ||
Qt::KeyboardModifiers | modifiers | ||
) |
Constructs a mouse event object.
The type parameter must be one of QEvent::MouseButtonPress, QEvent::MouseButtonRelease, QEvent::MouseButtonDblClick, or QEvent::MouseMove.
The position is the mouse cursor's position relative to the receiving widget. The button that caused the event is given as a value from the Qt::MouseButton enum. If the event type is MouseMove , the appropriate button for this event is Qt::NoButton. The mouse and keyboard states at the time of the event are specified by buttons and modifiers.
The globalPos() is initialized to QCursor::pos(), which may not be appropriate. Use the other constructor to specify the global position explicitly.
Definition at line 180 of file qevent.cpp.
Referenced by ~QMouseEvent().
QMouseEvent::QMouseEvent | ( | Type | type, |
const QPoint & | pos, | ||
const QPoint & | globalPos, | ||
Qt::MouseButton | button, | ||
Qt::MouseButtons | buttons, | ||
Qt::KeyboardModifiers | modifiers | ||
) |
Constructs a mouse event object.
The type parameter must be QEvent::MouseButtonPress, QEvent::MouseButtonRelease, QEvent::MouseButtonDblClick, or QEvent::MouseMove.
The pos is the mouse cursor's position relative to the receiving widget. The cursor's position in global coordinates is specified by globalPos. The button that caused the event is given as a value from the Qt::MouseButton enum. If the event type is MouseMove , the appropriate button for this event is Qt::NoButton. buttons is the state of all buttons at the time of the event, modifiers the state of all keyboard modifiers.
Definition at line 242 of file qevent.cpp.
QMouseEvent::~QMouseEvent | ( | ) |
Definition at line 190 of file qevent.cpp.
|
inline |
Returns the button that caused the event.
Note that the returned value is always Qt::NoButton for mouse move events.
Definition at line 101 of file qevent.h.
Referenced by QStyledItemDelegate::editorEvent(), QItemDelegate::editorEvent(), QStatusBar::event(), QMainWindow::event(), QWidgetResizeHandler::eventFilter(), QVistaHelper::eventFilter(), QAxServerBase::eventFilter(), QWhatsThisPrivate::eventFilter(), QBasicMouseEventTransition::eventTest(), QScriptEdit::extraAreaMouseEvent(), QDockWidgetPrivate::mouseDoubleClickEvent(), QMdiSubWindow::mouseDoubleClickEvent(), QSystemTrayIconSys::mouseDoubleClickEvent(), QLineEdit::mouseDoubleClickEvent(), QGraphicsView::mouseDoubleClickEvent(), QWorkspaceTitleBar::mouseDoubleClickEvent(), QAbstractItemView::mouseDoubleClickEvent(), QMdi::ControlLabel::mouseDoubleClickEvent(), QMenuPrivate::mouseEventTaken(), QGraphicsViewPrivate::mouseMoveEventHandler(), QSizeGrip::mousePressEvent(), QScrollBar::mousePressEvent(), QDial::mousePressEvent(), QMDIControl::mousePressEvent(), QGroupBox::mousePressEvent(), QSlider::mousePressEvent(), QToolButton::mousePressEvent(), QDockWidgetPrivate::mousePressEvent(), QToolBarPrivate::mousePressEvent(), QBalloonTip::mousePressEvent(), QMdiSubWindow::mousePressEvent(), QVistaHelper::mousePressEvent(), QMenuBar::mousePressEvent(), QAbstractButton::mousePressEvent(), QAbstractSpinBox::mousePressEvent(), QWhatsThat::mousePressEvent(), QSystemTrayIconSys::mousePressEvent(), QSplitterHandle::mousePressEvent(), QTabBar::mousePressEvent(), QHeaderView::mousePressEvent(), QLineEdit::mousePressEvent(), QComboBox::mousePressEvent(), QGraphicsView::mousePressEvent(), QWorkspaceTitleBar::mousePressEvent(), QMdi::ControlLabel::mousePressEvent(), QMdi::ControllerWidget::mousePressEvent(), QMdiAreaTabBar::mousePressEvent(), QCalendarView::mousePressEvent(), QSizeGrip::mouseReleaseEvent(), QScrollBar::mouseReleaseEvent(), QDial::mouseReleaseEvent(), QMDIControl::mouseReleaseEvent(), QGroupBox::mouseReleaseEvent(), QDockWidgetPrivate::mouseReleaseEvent(), QMdiSubWindow::mouseReleaseEvent(), QMenuBar::mouseReleaseEvent(), QAbstractButton::mouseReleaseEvent(), QWhatsThat::mouseReleaseEvent(), QMenu::mouseReleaseEvent(), QSplitterHandle::mouseReleaseEvent(), QTabBar::mouseReleaseEvent(), QLineEdit::mouseReleaseEvent(), QPlainTextEdit::mouseReleaseEvent(), QGraphicsView::mouseReleaseEvent(), QWorkspaceTitleBar::mouseReleaseEvent(), QTextEdit::mouseReleaseEvent(), QMdi::ControlLabel::mouseReleaseEvent(), QMdi::ControllerWidget::mouseReleaseEvent(), QCalendarView::mouseReleaseEvent(), QApplication::notify(), QTriangulator< T >::ComplexToSimple::Event::operator<(), operator<<(), QTextControl::processEvent(), QLineControl::processMouseEvent(), and ~QMouseEvent().
|
inline |
Returns the button state when the event was generated.
The button state is a combination of Qt::LeftButton, Qt::RightButton, Qt::MidButton using the OR operator. For mouse move events, this is all buttons that are pressed down. For mouse press and double click events this includes the button that caused the event. For mouse release events this excludes the button that caused the event.
Definition at line 102 of file qevent.h.
Referenced by QMainWindow::event(), QWidgetResizeHandler::eventFilter(), QAxServerBase::eventFilter(), QScriptEdit::extraAreaMouseEvent(), QGraphicsView::mouseDoubleClickEvent(), QMenuPrivate::mouseEventTaken(), QmlJSDebugger::ToolBarColorBox::mouseMoveEvent(), QmlJSDebugger::ZoomTool::mouseMoveEvent(), QSizeGrip::mouseMoveEvent(), QScrollBar::mouseMoveEvent(), QDial::mouseMoveEvent(), QMdiSubWindow::mouseMoveEvent(), QMenuBar::mouseMoveEvent(), QAbstractButton::mouseMoveEvent(), QmlJSDebugger::AbstractViewInspector::mouseMoveEvent(), QMenu::mouseMoveEvent(), QSplitterHandle::mouseMoveEvent(), QTabBar::mouseMoveEvent(), QHeaderView::mouseMoveEvent(), QLineEdit::mouseMoveEvent(), QPlainTextEdit::mouseMoveEvent(), QGraphicsView::mouseMoveEvent(), QWorkspaceTitleBar::mouseMoveEvent(), QTextEdit::mouseMoveEvent(), QAbstractItemView::mouseMoveEvent(), QGraphicsViewPrivate::mouseMoveEventHandler(), QmlJSDebugger::ZoomTool::mousePressEvent(), QmlJSDebugger::LiveSelectionTool::mousePressEvent(), QScrollBar::mousePressEvent(), QDial::mousePressEvent(), QSlider::mousePressEvent(), QGraphicsView::mousePressEvent(), QScrollBar::mouseReleaseEvent(), QDial::mouseReleaseEvent(), QSlider::mouseReleaseEvent(), QGraphicsView::mouseReleaseEvent(), QApplication::notify(), QTriangulator< T >::ComplexToSimple::Event::operator<(), operator<<(), QTextControl::processEvent(), and QLineControl::processMouseEvent().
|
static |
Definition at line 251 of file qevent.cpp.
Referenced by QGraphicsProxyWidgetPrivate::sendWidgetMouseEvent().
|
inline |
Returns the global position of the mouse cursor at the time of the event.
This is important on asynchronous window systems like X11. Whenever you move your widgets around in response to mouse events, globalPos() may differ a lot from the current pointer position QCursor::pos(), and from QWidget::mapToGlobal(pos()).
Definition at line 96 of file qevent.h.
Referenced by QWidgetResizeHandler::eventFilter(), QMdiSubWindow::eventFilter(), QWhatsThisPrivate::eventFilter(), QScriptEdit::extraAreaMouseEvent(), QMenuPrivate::mouseEventTaken(), QSizeGrip::mouseMoveEvent(), QWidgetResizeHandler::mouseMoveEvent(), QDockWidgetPrivate::mouseMoveEvent(), QToolBarPrivate::mouseMoveEvent(), QTipLabel::mouseMoveEvent(), QSplitterHandle::mouseMoveEvent(), QWorkspaceTitleBar::mouseMoveEvent(), QGraphicsViewPrivate::mouseMoveEventHandler(), QmlJSDebugger::ZoomTool::mousePressEvent(), QSizeGrip::mousePressEvent(), QmlJSDebugger::LiveSelectionTool::mousePressEvent(), QMenuBar::mousePressEvent(), QMenu::mousePressEvent(), QSystemTrayIconSys::mousePressEvent(), QCalendarPopup::mousePressEvent(), QComboBoxPrivateContainer::mousePressEvent(), QMenu::mouseReleaseEvent(), QSplitterHandle::mouseReleaseEvent(), QGraphicsView::mouseReleaseEvent(), QDockWidgetPrivate::nonClientAreaMouseEvent(), QApplication::notify(), QTextControl::processEvent(), QTapAndHoldGestureRecognizer::recognize(), QApplicationPrivate::sendMouseEvent(), and ~QMouseEvent().
|
inline |
Returns the global x position of the mouse cursor at the time of the event.
Definition at line 99 of file qevent.h.
Referenced by QVistaHelper::eventFilter().
|
inline |
Returns the global y position of the mouse cursor at the time of the event.
Definition at line 100 of file qevent.h.
Referenced by QVistaHelper::eventFilter().
|
inline |
Definition at line 107 of file qevent.h.
Referenced by posF().
|
inline |
Returns the position of the mouse cursor, relative to the widget that received the event.
If you move the widget as a result of the mouse event, use the global position returned by globalPos() to avoid a shaking motion.
Definition at line 95 of file qevent.h.
Referenced by QGraphicsViewPrivate::_q_unsetViewportCursor(), QStyledItemDelegate::editorEvent(), QItemDelegate::editorEvent(), QStatusBar::event(), QMainWindow::event(), QComboBoxPrivateContainer::eventFilter(), QWhatsThisPrivate::eventFilter(), QBasicMouseEventTransition::eventTest(), QScriptEdit::extraAreaMouseEvent(), QmlJSDebugger::LiveSelectionTool::hoverMoveEvent(), QDockWidgetPrivate::mouseDoubleClickEvent(), QTreeView::mouseDoubleClickEvent(), QHeaderView::mouseDoubleClickEvent(), QLineEdit::mouseDoubleClickEvent(), QWorkspaceTitleBar::mouseDoubleClickEvent(), QAbstractItemView::mouseDoubleClickEvent(), QmlJSDebugger::ColorPickerTool::mouseMoveEvent(), QmlJSDebugger::ToolBarColorBox::mouseMoveEvent(), QmlJSDebugger::ZoomTool::mouseMoveEvent(), QmlJSDebugger::LiveSelectionTool::mouseMoveEvent(), QRadioButton::mouseMoveEvent(), QScrollBar::mouseMoveEvent(), QCheckBox::mouseMoveEvent(), QmlJSDebugger::QDeclarativeViewInspector::mouseMoveEvent(), QDial::mouseMoveEvent(), QMDIControl::mouseMoveEvent(), QGroupBox::mouseMoveEvent(), QSlider::mouseMoveEvent(), QDockWidgetPrivate::mouseMoveEvent(), QToolBarPrivate::mouseMoveEvent(), QMdiSubWindow::mouseMoveEvent(), QVistaHelper::mouseMoveEvent(), QMenuBar::mouseMoveEvent(), QAbstractButton::mouseMoveEvent(), QAbstractSpinBox::mouseMoveEvent(), QListView::mouseMoveEvent(), QWhatsThat::mouseMoveEvent(), QMenu::mouseMoveEvent(), QComboBoxPrivateScroller::mouseMoveEvent(), QTabBar::mouseMoveEvent(), QTreeView::mouseMoveEvent(), QLineEdit::mouseMoveEvent(), QPlainTextEdit::mouseMoveEvent(), QGraphicsView::mouseMoveEvent(), QWorkspaceTitleBar::mouseMoveEvent(), QTextEdit::mouseMoveEvent(), QColorWell::mouseMoveEvent(), QMdi::ControllerWidget::mouseMoveEvent(), QColorPicker::mouseMoveEvent(), QColorShowLabel::mouseMoveEvent(), QGraphicsViewPrivate::mouseMoveEventHandler(), QmlJSDebugger::ColorPickerTool::mousePressEvent(), QmlJSDebugger::ZoomTool::mousePressEvent(), QmlJSDebugger::LiveSelectionTool::mousePressEvent(), QScrollBar::mousePressEvent(), QDial::mousePressEvent(), QMDIControl::mousePressEvent(), QGroupBox::mousePressEvent(), QSlider::mousePressEvent(), QToolButton::mousePressEvent(), QDockWidgetPrivate::mousePressEvent(), QToolBarPrivate::mousePressEvent(), QMdiSubWindow::mousePressEvent(), QVistaHelper::mousePressEvent(), QMenuBar::mousePressEvent(), QAbstractButton::mousePressEvent(), QAbstractSpinBox::mousePressEvent(), QWellArray::mousePressEvent(), QWhatsThat::mousePressEvent(), QMenu::mousePressEvent(), QCalendarPopup::mousePressEvent(), QSplitterHandle::mousePressEvent(), QDateTimeEdit::mousePressEvent(), QTabBar::mousePressEvent(), QTreeView::mousePressEvent(), QLineEdit::mousePressEvent(), QComboBox::mousePressEvent(), QWorkspaceTitleBar::mousePressEvent(), QColorWell::mousePressEvent(), QMdi::ControllerWidget::mousePressEvent(), QMdiAreaTabBar::mousePressEvent(), QColorPicker::mousePressEvent(), QWidget::mousePressEvent(), QColorShowLabel::mousePressEvent(), QmlJSDebugger::ZoomTool::mouseReleaseEvent(), QmlJSDebugger::LiveSelectionTool::mouseReleaseEvent(), QDial::mouseReleaseEvent(), QMDIControl::mouseReleaseEvent(), QGroupBox::mouseReleaseEvent(), QMdiSubWindow::mouseReleaseEvent(), QVistaHelper::mouseReleaseEvent(), QMenuBar::mouseReleaseEvent(), QAbstractButton::mouseReleaseEvent(), QWhatsThat::mouseReleaseEvent(), QMenu::mouseReleaseEvent(), QTabBar::mouseReleaseEvent(), QTreeView::mouseReleaseEvent(), QLineEdit::mouseReleaseEvent(), QPlainTextEdit::mouseReleaseEvent(), QGraphicsView::mouseReleaseEvent(), QWorkspaceTitleBar::mouseReleaseEvent(), QTextEdit::mouseReleaseEvent(), QMdi::ControllerWidget::mouseReleaseEvent(), QDockWidgetPrivate::nonClientAreaMouseEvent(), QApplication::notify(), QTriangulator< T >::ComplexToSimple::Event::operator<(), posF(), QTextControl::processEvent(), QLineControl::processMouseEvent(), QmlJSDebugger::LiveSelectionTool::selectUnderPoint(), QLineEditPrivate::sendMouseEventToInputContext(), QGraphicsViewPrivate::storeMouseEvent(), and ~QMouseEvent().
QPointF QMouseEvent::posF | ( | ) | const |
Returns the position of the mouse cursor as a QPointF, relative to the widget that received the event.
If you move the widget as a result of the mouse event, use the global position returned by globalPos() to avoid a shaking motion.
Definition at line 278 of file qevent.cpp.
|
inline |
Returns the x position of the mouse cursor, relative to the widget that received the event.
Definition at line 97 of file qevent.h.
Referenced by QAxServerBase::eventFilter(), QHeaderView::mouseDoubleClickEvent(), QHeaderView::mouseMoveEvent(), QHeaderView::mousePressEvent(), and QHeaderView::mouseReleaseEvent().
|
inline |
Returns the y position of the mouse cursor, relative to the widget that received the event.
Definition at line 98 of file qevent.h.
Referenced by QAxServerBase::eventFilter(), QTreeView::mouseDoubleClickEvent(), QHeaderView::mouseDoubleClickEvent(), QHeaderView::mouseMoveEvent(), QColorLuminancePicker::mouseMoveEvent(), QHeaderView::mousePressEvent(), QColorLuminancePicker::mousePressEvent(), and QHeaderView::mouseReleaseEvent().
|
protected |
Definition at line 121 of file qevent.h.
Referenced by ~QMouseEvent().
|
protected |
Definition at line 120 of file qevent.h.
Referenced by QMouseEvent(), and ~QMouseEvent().
|
protected |
Definition at line 122 of file qevent.h.
Referenced by ~QMouseEvent().
|
protected |
Definition at line 120 of file qevent.h.
Referenced by ~QMouseEvent().