Logo Search packages:      
Sourcecode: qt4-x11 version File versions

void QWidget::grabMouse (  )  [inherited]

Grabs the mouse input.

This widget receives all mouse events until releaseMouse() is called; other widgets get no mouse events at all. Keyboard events are not affected. Use grabKeyboard() if you want to grab that.

Bugs in mouse-grabbing applications very often lock the terminal. Use this function with extreme caution, and consider using the -nograb command line option while debugging.
It is almost never necessary to grab the mouse when using Qt, as Qt grabs and releases it sensibly. In particular, Qt grabs the mouse when a mouse button is pressed and keeps it until the last button is released.

Note that only visible widgets can grab mouse input. If isVisible() returns false for a widget, that widget cannot call grabMouse().

See also:
releaseMouse() grabKeyboard() releaseKeyboard() grabKeyboard() focusWidget()

Definition at line 1289 of file qwidget_x11.cpp.

References QWidget::effectiveWinId(), QWidget::releaseMouse(), and QWidget::testAttribute().

    if (isVisible() && !qt_nograb()) {
        if (QWidgetPrivate::mouseGrabber && QWidgetPrivate::mouseGrabber != this)
#ifndef QT_NO_DEBUG
        int status =
            XGrabPointer(X11->display, effectiveWinId(), False,
                          (uint)(ButtonPressMask | ButtonReleaseMask |
                                  PointerMotionMask | EnterWindowMask |
                          GrabModeAsync, GrabModeAsync,
                          XNone, XNone, X11->time);
#ifndef QT_NO_DEBUG
        if (status) {
            const char *s =
                status == GrabNotViewable ? "\"GrabNotViewable\"" :
                status == AlreadyGrabbed  ? "\"AlreadyGrabbed\"" :
                status == GrabFrozen      ? "\"GrabFrozen\"" :
                status == GrabInvalidTime ? "\"GrabInvalidTime\"" :
            qWarning("QWidget::grabMouse: Failed with %s", s);
        QWidgetPrivate::mouseGrabber = this;

Generated by  Doxygen 1.6.0   Back to index