Qt logo

QMouseEvent Class Reference


The QMouseEvent class contains parameters that describe a mouse event. More...

#include <qevent.h>

Inherits QEvent.

List of all member functions.

Public Members


Detailed Description

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 only occur when some mouse button is pressed down, unless mouse tracking has been enabled.

Qt makes an automatic mouse grab when a mouse button is pressed inside a widget, and the widget will continue to receive mouse events until the last mouse button is released.

The QWidget::setEnable() function can be used to enable or disable mouse and keyboard events for a widget.

The QCursor widget has static functions for reading and setting the position of the mouse cursor.

The event handlers QWidget::mousePressEvent(), QWidget::mouseReleaseEvent(), QWidget::mouseDoubleClickEvent() and QWidget::mouseMoveEvent() receive mouse events.

See also: QWidget::setMouseTracking() and QWidget::grabMouse().

Examples: qtimage/qtimage.cpp table/table.cpp life/life.cpp dclock/dclock.cpp connect/connect.cpp trivial/trivial.cpp tooltip/tooltip.cpp hello/hello.cpp movies/main.cpp qmag/qmag.cpp showimg/showimg.cpp biff/biff.cpp widgets/widgets.cpp


Member Function Documentation

QMouseEvent::QMouseEvent ( int type, const QPoint & pos, int button, int state )

Constructs a mouse event object.

The type parameter must be Event_MouseButtonPress, Event_MouseButtonRelease, Event_MouseButtonDblClick or

The typs widget updates if enable is TRUE, or disables widget updates if enable is FALSE.

Calling update() and repaint() has no effect if updates are disabled. Paint events from the window system are processed as normally even if updates are disabled.

This function is normally used to disable updates for a short period of time, for instance to avoid screen flicker during large changes.

Example:

    setUpdatesEnabled( FALSE );
    bigVisualChanges();
    setUpdatesEnabled( TRUE );
    repaint();

See also: isUpdatesEnabled(), update(), repaint() and paintEvent().

void QWidget::setWFlags ( WFlags f ) [protected]

For internal use only.

void QWidget::show () [virtual slot]

Shows the widget and its child widgets.

If its size or position has changed, Qt guarantees that a widget gets move and resize events just before the widget is shown.

See also: hide(), iconify() and isVisible().

Examples: forever/forever.cpp connect/connect.cpp mainlyQt/editor.cpp drawdemo/drawdemo.cpp movies/main.cpp picture/picture.cpp xform/xform.cpp menu/menu.cpp pref/pref.cpp progress/progress.cpp cursor/cursor.cpp layout/layout.cpp qmag/qmag.cpp showimg/showimg.cpp widgets/widgets.cpp

Reimplemented in QTableView, QTabBar, QToolBar, QSemiModal, QListView, QPopupMenu, QDialog, QMainWindow, QScrollView, QMenuBar, QTabDialog and QWidgetStack.

QSize QWidget::size () const

Returns the size of the widget, excluding the window frame.

See also: geometry(), width() and height().

QSize QWidget::sizeHint () const [virtual]

Returns a recommended size for the widget, or an invalid size if no size is recommended.

The default implementation returns an invalid size.

See also: QSize::isValid(), resize() and setMinimumSize().

Examples: widgets/widgets.cpp

Reimplemented in QToolButton, QPushButton, QSpinBox, QListBox, QTabBar, QHeader, QLCDNumber, QListView, QScrollBar, QLineEdit, QCheckBox, QProgressDialog, QRadioButton, QLabel, QComboBox,