⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qevent.cpp

📁 奇趣公司比较新的qt/emd版本
💻 CPP
📖 第 1 页 / 共 5 页
字号:
    of the event, \a delta contains the rotation distance,    \a modifiers holds the keyboard modifier flags at the time of the    event, and \a orient holds the wheel's orientation.    \sa pos() delta() state()*/#ifndef QT_NO_WHEELEVENTQWheelEvent::QWheelEvent(const QPoint &pos, int delta,                         Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers,                         Qt::Orientation orient)    : QInputEvent(Wheel, modifiers), p(pos), d(delta), mouseState(buttons), o(orient){    g = QCursor::pos();}/*!  \internal*/QWheelEvent::~QWheelEvent(){}#ifdef QT3_SUPPORT/*!    Use one of the other constructors instead.*/QWheelEvent::QWheelEvent(const QPoint &pos, int delta, int state, Qt::Orientation orient)    : QInputEvent(Wheel), p(pos), d(delta), o(orient){    g = QCursor::pos();    mouseState = Qt::MouseButtons(state & Qt::MouseButtonMask);    modState = Qt::KeyboardModifiers(state & (int)Qt::KeyButtonMask);}#endif/*!    Constructs a wheel event object.    The \a pos provides the location of the mouse cursor    within the widget. The position in global coordinates is specified    by \a globalPos. \a delta contains the rotation distance, \a modifiers    holds the keyboard modifier flags at the time of the event, and    \a orient holds the wheel's orientation.    \sa pos() globalPos() delta() state()*/QWheelEvent::QWheelEvent(const QPoint &pos, const QPoint& globalPos, int delta,                         Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers,                         Qt::Orientation orient)    : QInputEvent(Wheel, modifiers), p(pos), g(globalPos), d(delta), mouseState(buttons), o(orient){}#ifdef QT3_SUPPORT/*!    Use one of the other constructors instead.*/QWheelEvent::QWheelEvent(const QPoint &pos, const QPoint& globalPos, int delta, int state,                         Qt::Orientation orient)    : QInputEvent(Wheel), p(pos), g(globalPos), d(delta), o(orient){    mouseState = Qt::MouseButtons(state & Qt::MouseButtonMask);    modState = Qt::KeyboardModifiers(state & (int) Qt::KeyButtonMask);}#endif#endif // QT_NO_WHEELEVENT/*!    \fn int QWheelEvent::delta() const    Returns the distance that the wheel is rotated, in eighths of a    degree. A positive value indicates that the wheel was rotated    forwards away from the user; a negative value indicates that the    wheel was rotated backwards toward the user.    Most mouse types work in steps of 15 degrees, in which case the    delta value is a multiple of 120; i.e., 120 * 1/8 = 15.    Example:    \code        void MyWidget::wheelEvent(QWheelEvent *event)        {            int numDegrees = event->delta() / 8;            int numSteps = numDegrees / 15;            if (event->orientation() == Qt::Horizontal) {                scrollHorizontally(numSteps);            } else {                scrollVertically(numSteps);            }            event->accept();        }    \endcode*//*!    \fn const QPoint &QWheelEvent::pos() const    Returns the position of the mouse cursor relative to the widget    that received the event.    If you move your widgets around in response to mouse events,    use globalPos() instead of this function.    \sa x() y() globalPos()*//*!    \fn int QWheelEvent::x() const    Returns the x position of the mouse cursor, relative to the    widget that received the event.    \sa y() pos()*//*!    \fn int QWheelEvent::y() const    Returns the y position of the mouse cursor, relative to the    widget that received the event.    \sa x() pos()*//*!    \fn const QPoint &QWheelEvent::globalPos() const    Returns the global position of the mouse pointer \e{at the time    of the event}. This is important on asynchronous window systems    such as X11; whenever you move your widgets around in response to    mouse events, globalPos() can differ a lot from the current    cursor position returned by QCursor::pos().    \sa globalX() globalY()*//*!    \fn int QWheelEvent::globalX() const    Returns the global x position of the mouse cursor at the time of    the event.    \sa globalY() globalPos()*//*!    \fn int QWheelEvent::globalY() const    Returns the global y position of the mouse cursor at the time of    the event.    \sa globalX() globalPos()*//*! \obsolete    \fn Qt::ButtonState QWheelEvent::state() const    Returns the keyboard modifier flags at the time of the event.    The returned value is a selection of the following values,    combined using the OR operator: Qt::ShiftButton,    Qt::ControlButton, and Qt::AltButton.*//*!    \class QKeyEvent    \brief The QKeyEvent class contains describes a key event.    \ingroup events    Key events are sent to the widget with keyboard input focus    when keys are pressed or released.    A key event contains a special accept flag that indicates whether    the receiver will handle the key event. You should call ignore()    if the key press or release event is not handled by your widget.    A key event is propagated up the parent widget chain until a    widget accepts it with accept() or an event filter consumes it.    Key events for multimedia keys are ignored by default. You should    call accept() if your widget handles those events.    The QWidget::setEnable() function can be used to enable or disable    mouse and keyboard events for a widget.    The event handlers QWidget::keyPressEvent() and    QWidget::keyReleaseEvent() receive key events.    \sa QFocusEvent, QWidget::grabKeyboard()*//*!    Constructs a key event object.    The \a type parameter must be QEvent::KeyPress, QEvent::KeyRelease,    or QEvent::ShortcutOverride.    If \a key is 0, the event is not a result of    a known key; for example, it may be the result of a compose    sequence or keyboard macro. The \a modifiers holds the keyboard    modifiers, and the given \a text is the Unicode text that the    key generated. If \a autorep is true, isAutoRepeat() will be    true. \a count is the number of keys involved in the event.*/QKeyEvent::QKeyEvent(Type type, int key, Qt::KeyboardModifiers modifiers, const QString& text,                     bool autorep, ushort count)    : QInputEvent(type, modifiers), txt(text), k(key), c(count), autor(autorep){}/*!  \internal*/QKeyEvent::~QKeyEvent(){}/*!    \internal*/QKeyEvent *QKeyEvent::createExtendedKeyEvent(Type type, int key, Qt::KeyboardModifiers modifiers,                                             quint32 nativeScanCode, quint32 nativeVirtualKey,                                             quint32 nativeModifiers,                                             const QString& text, bool autorep, ushort count){    return new QKeyEventEx(type, key, modifiers, text, autorep, count,                           nativeScanCode, nativeVirtualKey, nativeModifiers);}/*!    \fn bool QKeyEvent::hasExtendedInfo() const    \internal*//*!    \since 4.2    Returns the native scan code of the key event.    If the key event does not contain this data 0 is returned.    Note: The native scan code may be 0, even if the key event contains extended information.*/quint32 QKeyEvent::nativeScanCode() const{    return (reinterpret_cast<const QKeyEvent*>(d) != this            ? 0 : reinterpret_cast<const QKeyEventEx*>(this)->nScanCode);}/*!    \since 4.2    Returns the native virtual key, or key sym of the key event.    If the key event does not contain this data 0 is returned.    Note: The native virtual key may be 0, even if the key event contains extended information.*/quint32 QKeyEvent::nativeVirtualKey() const{    return (reinterpret_cast<const QKeyEvent*>(d) != this            ? 0 : reinterpret_cast<const QKeyEventEx*>(this)->nVirtualKey);}/*!    \since 4.2    Returns the native modifiers of a key event.    If the key event does not contain this data 0 is returned.    Note: The native modifiers may be 0, even if the key event contains extended information.*/quint32 QKeyEvent::nativeModifiers() const{    return (reinterpret_cast<const QKeyEvent*>(d) != this            ? 0 : reinterpret_cast<const QKeyEventEx*>(this)->nModifiers);}/*!    \internal    Creates an extended key event object, which in addition to the normal key event data, also    contains the native scan code, virtual key and modifiers. This extra data is used by the    shortcut system, to determine which shortcuts to trigger.*/QKeyEventEx::QKeyEventEx(Type type, int key, Qt::KeyboardModifiers modifiers,                         const QString &text, bool autorep, ushort count,                         quint32 nativeScanCode, quint32 nativeVirtualKey, quint32 nativeModifiers)    : QKeyEvent(type, key, modifiers, text, autorep, count),      nScanCode(nativeScanCode), nVirtualKey(nativeVirtualKey), nModifiers(nativeModifiers){    d = reinterpret_cast<QEventPrivate*>(this);}/*!    \internal    Creates a copy of an other extended key event.*/QKeyEventEx::QKeyEventEx(const QKeyEventEx &other)    : QKeyEvent(QEvent::Type(other.t), other.k, other.modState, other.txt, other.autor, other.c),      nScanCode(other.nScanCode), nVirtualKey(other.nVirtualKey), nModifiers(other.nModifiers){    d = reinterpret_cast<QEventPrivate*>(this);}/*!    \internal*/QKeyEventEx::~QKeyEventEx(){}/*!    \fn int QKeyEvent::key() const    Returns the code of the key that was pressed or released.    See \l Qt::Key for the list of keyboard codes. These codes are    independent of the underlying window system. Note that this    function does not distinguish between capital and non-capital    letters, use the text() function (returning the Unicode text the    key generated) for this purpose.    A value of either 0 or Qt::Key_unknown means that the event is not    the result of a known key; for example, it may be the result of    a compose sequence, a keyboard macro, or due to key event    compression.    \sa Qt::WA_KeyCompression*//*!    \fn QString QKeyEvent::text() const    Returns the Unicode text that this key generated. The text    returned can be an empty string in cases    where modifier keys, such as Shift, Control, Alt, and Meta,    are being pressed or released. In such cases key() will contain    a valid value.    \sa Qt::WA_KeyCompression*//*!    Returns the keyboard modifier flags that existed immediately    after the event occurred.    \warning This function cannot always be trusted. The user can    confuse it by pressing both \key{Shift} keys simultaneously and    releasing one of them, for example.    \sa QApplication::keyboardModifiers()*///###### We must check with XGetModifierMappingQt::KeyboardModifiers QKeyEvent::modifiers() const{    if (key() == Qt::Key_Shift)        return Qt::KeyboardModifiers(QInputEvent::modifiers()^Qt::ShiftModifier);    if (key() == Qt::Key_Control)        return Qt::KeyboardModifiers(QInputEvent::modifiers()^Qt::ControlModifier);    if (key() == Qt::Key_Alt)        return Qt::KeyboardModifiers(QInputEvent::modifiers()^Qt::AltModifier);    if (key() == Qt::Key_Meta)        return Qt::KeyboardModifiers(QInputEvent::modifiers()^Qt::MetaModifier);    return QInputEvent::modifiers();}#ifndef QT_NO_SHORTCUT/*!    \fn bool QKeyEvent::matches(QKeySequence::StandardKey key) const    \since 4.2    Returns true if the key event matches the given standard \a key;    otherwise returns false.*/bool QKeyEvent::matches(QKeySequence::StandardKey matchKey) const{    uint searchkey = (modifiers() | key()) & ~(Qt::KeypadModifier); //The keypad modifier should not make a difference    uint platform = QApplicationPrivate::currentPlatform();    uint N = QKeySequencePrivate::numberOfKeyBindings;    int first = 0;    int last = N - 1;    while (first <= last) {        int mid = (first + last) / 2;        QKeyBinding midVal = QKeySequencePrivate::keyBindings[mid];        if (searchkey > midVal.shortcut){            first = mid + 1;  // Search in top half        }        else if (searchkey < midVal.shortcut){            last = mid - 1; // Search in bottom half        }        else {            //found correct shortcut value, now we must check for platform match            if ((midVal.platform & platform) && (midVal.standardKey == matchKey)) {                return true;            } else { //We may have several equal values for different platforms, so we must search in both directions                //search forward                for ( unsigned int i = mid + 1 ; i < N - 1 ; ++i) {                    QKeyBinding current = QKeySequencePrivate::keyBindings[i];                    if (current.shortcut != searchkey)                        break;                    else if (current.platform & platform && current.standardKey == matchKey)                        return true;                }                //search back                for ( int i = mid - 1 ; i >= 0 ; --i) {                    QKeyBinding current = QKeySequencePrivate::keyBindings[i];                    if (current.shortcut != searchkey)                        break;                    else if (current.platform & platform && current.standardKey == matchKey)                        return true;                }                return false; //we could not find it among the matching keySequences            }        }    }    return false; //we could not find matching keySequences at all}#endif // QT_NO_SHORTCUT/*!    \fn bool QKeyEvent::isAutoRepeat() const

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -