当前位置: 首页>>代码示例>>C++>>正文


C++ QShortcutEvent类代码示例

本文整理汇总了C++中QShortcutEvent的典型用法代码示例。如果您正苦于以下问题:C++ QShortcutEvent类的具体用法?C++ QShortcutEvent怎么用?C++ QShortcutEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了QShortcutEvent类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Q_D

/*!\reimp
*/
bool QLabel::event(QEvent *e)
{
    Q_D(QLabel);
    QEvent::Type type = e->type();

#ifndef QT_NO_SHORTCUT
    if (type == QEvent::Shortcut) {
        QShortcutEvent *se = static_cast<QShortcutEvent *>(e);
        if (se->shortcutId() == d->shortcutId) {
            QWidget * w = d->buddy;
            QAbstractButton *button = qobject_cast<QAbstractButton *>(w);
            if (w->focusPolicy() != Qt::NoFocus)
                w->setFocus(Qt::ShortcutFocusReason);
            if (button && !se->isAmbiguous())
                button->animateClick();
            else
                window()->setAttribute(Qt::WA_KeyboardFocusChange);
            return true;
        }
    } else
#endif
    if (type == QEvent::Resize) {
        if (d->control)
            d->textLayoutDirty = true;
    } else if (e->type() == QEvent::StyleChange
#ifdef Q_WS_MAC
               || e->type() == QEvent::MacSizeChange
#endif
               ) {
        d->setLayoutItemMargins(QStyle::SE_LabelLayoutItem);
        d->updateLabel();
    }

    return QFrame::event(e);
}
开发者ID:muromec,项目名称:qtopia-ezx,代码行数:37,代码来源:qlabel.cpp

示例2: event

bool QQuickShortcut::event(QEvent *event)
{
    if (m_enabled && event->type() == QEvent::Shortcut) {
        QShortcutEvent *se = static_cast<QShortcutEvent *>(event);
        if (se->shortcutId() == m_id && se->key() == m_shortcut){
            if (se->isAmbiguous())
                emit activatedAmbiguously();
            else
                emit activated();
            return true;
        }
    }
    return false;
}
开发者ID:2gis,项目名称:2gisqt5android,代码行数:14,代码来源:qquickshortcut.cpp

示例3: event

bool ScTreeWidget::event(QEvent *e)
{
    if (e->type() == QEvent::Shortcut)
    {
        QShortcutEvent *se = static_cast<QShortcutEvent *>(e);
        if (se != NULL)
        {
            int k = se->shortcutId();
            QTreeWidgetItem *item1 = keySList.value(k);
            handleMousePress(item1);
            return true;
        }
    }
    return QTreeWidget::event(e);
}
开发者ID:gyuris,项目名称:scribus,代码行数:15,代码来源:sctreewidget.cpp

示例4: event

/*!
  \reimp
*/
bool
QAction::event(QEvent *e)
{
#ifndef QT_NO_SHORTCUT
    if (e->type() == QEvent::Shortcut) {
        QShortcutEvent *se = static_cast<QShortcutEvent *>(e);
        Q_ASSERT_X(se->key() == d_func()->shortcut || d_func()->alternateShortcuts.contains(se->key()),
                   "QAction::event",
                   "Received shortcut event from incorrect shortcut");
        if (se->isAmbiguous())
            qWarning("QAction::eventFilter: Ambiguous shortcut overload: %s", se->key().toString(QKeySequence::NativeText).toLatin1().constData());
        else
            activate(Trigger);
        return true;
    }
#endif
    return QObject::event(e);
}
开发者ID:3163504123,项目名称:phantomjs,代码行数:21,代码来源:qaction.cpp

示例5: event

bool QQuickAction::event(QEvent *e)
{
    if (!m_enabled)
        return false;

    if (e->type() != QEvent::Shortcut)
        return false;

    QShortcutEvent *se = static_cast<QShortcutEvent *>(e);

    Q_ASSERT_X(se->key() == m_shortcut || se->key() == m_mnemonic,
               "QQuickAction::event",
               "Received shortcut event from incorrect shortcut");
    if (se->isAmbiguous()) {
        qWarning("QQuickAction::event: Ambiguous shortcut overload: %s", se->key().toString(QKeySequence::NativeText).toLatin1().constData());
        return false;
    }

    trigger();

    return true;
}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:22,代码来源:qquickaction.cpp

示例6: Q_D

/*!
    \internal
*/
bool QShortcut::event(QEvent *e)
{
    Q_D(QShortcut);
    bool handled = false;
    if (d->sc_enabled && e->type() == QEvent::Shortcut) {
        QShortcutEvent *se = static_cast<QShortcutEvent *>(e);
        if (se->shortcutId() == d->sc_id && se->key() == d->sc_sequence){
#ifndef QT_NO_WHATSTHIS
            if (QWhatsThis::inWhatsThisMode()) {
                QWhatsThis::showText(QCursor::pos(), d->sc_whatsthis);
                handled = true;
            } else
#endif
            if (se->isAmbiguous())
                emit activatedAmbiguously();
            else
                emit activated();
            handled = true;
        }
    }
    return handled;
}
开发者ID:FlavioFalcao,项目名称:qt5,代码行数:25,代码来源:qshortcut.cpp

示例7: scene

bool Global::eventFilter(QObject * /*watched*/, QEvent * event)
{
    // Every single event delivered by Qt go through this method first before
    // going to its target object, so keep it as lightweight as possible

    // It is used as a convenient way to fix a few event behaviours that were
    // not quite right out of the box.

    // --------------------- Detect modifier key presses --------------

    // Detect modifier key presses (Shift, Ctrl, Alt, etc.) and update application
    // state accordingly (e.g., indicate which modifiers are pressed in the status bar, or
    // redraw the scene, since highlighting color depends on which modifiers are pressed)

    // If a modifier is pressed or released, update the modifier state, and emit a signal
    // if this state has changed
    // If a modifier is pressed or released, update the modifier state, and emit a signal
    // if this state has changed
    if(event->type() == QEvent::KeyPress ||
       event->type() == QEvent::KeyRelease)
    {
        QKeyEvent * keyEvent = static_cast<QKeyEvent *>(event);
        if(keyEvent)
        {
            // Workaround for Mac delete key
            // This is needed because of a bug in QT 5 that has not been resolved as of 5.5.0
#ifdef Q_OS_MAC
            if(keyEvent->key() == Qt::Key_Backspace)
            {
                scene()->smartDelete();
            }
#endif
            if(keyEvent->key() == Qt::Key_Shift ||
               keyEvent->key() == Qt::Key_Alt ||
               keyEvent->key() == Qt::Key_Meta ||
               keyEvent->key() == Qt::Key_AltGr ||
               keyEvent->key() == Qt::Key_Control)
            {
                updateModifiers();
            }
        }

        // Continue normal processing of the event
        return false;
    }
    else if(event->type() == QEvent::FocusIn )
    {
        updateModifiers();

        // Continue normal processing of the event
        return false;
    }

    // --------------------- Resolve shortcut overloads --------------

    // Resolve shortcut overloads
    else if(event->type() == QEvent::Shortcut)
    {
        QShortcutEvent * shortcutEvent = static_cast<QShortcutEvent *>(event);

        if(shortcutEvent->isAmbiguous())
        {
            QKeySequence key = shortcutEvent->key();
            resolveAmbiguousShortcuts(key);

            // Stop processing of the event
            return true;

        }
        else
        {
            // Continue normal processing of the event
            return false;
        }
    }

    // --------------------- Keep standard behaviour --------------

    // Continue normal processing of the event
    return false;
}
开发者ID:zedd4x,项目名称:vpaint,代码行数:81,代码来源:Global.cpp

示例8: Q_D

/*! \reimp  */
bool QGroupBox::event(QEvent *e)
{
    Q_D(QGroupBox);
#ifndef QT_NO_SHORTCUT
    if (e->type() == QEvent::Shortcut) {
        QShortcutEvent *se = static_cast<QShortcutEvent *>(e);
        if (se->shortcutId() == d->shortcutId) {
            if (!isCheckable()) {
                d->_q_fixFocus(Qt::ShortcutFocusReason);
            } else {
                d->click();
                setFocus(Qt::ShortcutFocusReason);
            }
            return true;
        }
    }
#endif
    QStyleOptionGroupBox box;
    initStyleOption(&box);
    switch (e->type()) {
    case QEvent::HoverEnter:
    case QEvent::HoverMove: {
        QStyle::SubControl control = style()->hitTestComplexControl(QStyle::CC_GroupBox, &box,
                                     static_cast<QHoverEvent *>(e)->pos(),
                                     this);
        bool oldHover = d->hover;
        d->hover = d->checkable && (control == QStyle::SC_GroupBoxLabel || control == QStyle::SC_GroupBoxCheckBox);
        if (oldHover != d->hover) {
            QRect rect = style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxCheckBox, this)
                         | style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxLabel, this);
            update(rect);
        }
        return true;
    }
    case QEvent::HoverLeave:
        d->hover = false;
        if (d->checkable) {
            QRect rect = style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxCheckBox, this)
                         | style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxLabel, this);
            update(rect);
        }
        return true;
    case QEvent::KeyPress: {
        QKeyEvent *k = static_cast<QKeyEvent*>(e);
        if (!k->isAutoRepeat() && (k->key() == Qt::Key_Select || k->key() == Qt::Key_Space)) {
            d->pressedControl = QStyle::SC_GroupBoxCheckBox;
            update(style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxCheckBox, this));
            return true;
        }
        break;
    }
    case QEvent::KeyRelease: {
        QKeyEvent *k = static_cast<QKeyEvent*>(e);
        if (!k->isAutoRepeat() && (k->key() == Qt::Key_Select || k->key() == Qt::Key_Space)) {
            bool toggle = (d->pressedControl == QStyle::SC_GroupBoxLabel
                           || d->pressedControl == QStyle::SC_GroupBoxCheckBox);
            d->pressedControl = QStyle::SC_None;
            if (toggle)
                d->click();
            return true;
        }
        break;
    }
    default:
        break;
    }
    return QWidget::event(e);
}
开发者ID:redanium,项目名称:qt,代码行数:69,代码来源:qgroupbox.cpp

示例9: if

bool TestFramework::eventFilter(QObject* obj, QEvent* e) 
{
	if (test_running_)
	{
//   		if (e == last_event_) return false;
//   		last_event_ = e;

		bool stop = false;
		if (e->type() == QEvent::KeyPress)
		{
			QKeyEvent* ke = dynamic_cast<QKeyEvent*>(e);
			// pause macro if pause key is pressed
			if (ke->key() == Qt::Key_Pause) stop = true;
			else if (ke->key() == Qt::Key_X && ke->modifiers() == Qt::AltModifier)
			{
				// if a user presses Alt-X: quit immediately
				abortTest();
				getMainControl()->quit(0);
				return true;
			}
		}
		else if (e->type() == QEvent::MouseButtonPress ||
						 e->type() == QEvent::MouseButtonRelease)
		{
			// abort macro if user presses mouse button:
			if (!RTTI::isKindOf<MyMouseEvent>(*e) && e->spontaneous())
			{
 				stop = true;
			}
		}
		else
		{
			return false;
		}

		if (stop)
		{
			abortTest();
			qApp->installEventFilter(this);
			return true;
		}

		return false;
	}
	
	// if test is paused and pause key is pressed->resume macro
	if (!recording_ && e->type() == QEvent::KeyPress && lines_.size() > 0)
	{
		QKeyEvent* ke = dynamic_cast<QKeyEvent*>(e);
		if (ke->key() == Qt::Key_Pause)
		{
			processEvent_();
			timer_.reset();
			timer_.start();
			test_running_ = true;
			thread_.start();
			return true;
		}

		return false;
	}

	if (!recording_) return false;

	if (!RTTI::isKindOf<QKeyEvent>(*e) &&
			!RTTI::isKindOf<QMouseEvent>(*e) &&
			!RTTI::isKindOf<QShortcutEvent>(*e))
	{
		return false;
	}

	if (e->type() == QEvent::ShortcutOverride) return false;
 	if (e->type() == QEvent::KeyRelease) return false;
	QMouseEvent* 		me = dynamic_cast<QMouseEvent*>(e);
	QKeyEvent* 			ke = dynamic_cast<QKeyEvent*>(e);
	QShortcutEvent* se = dynamic_cast<QShortcutEvent*>(e);

	if (ke != 0 && 
			ke->type() == QEvent::KeyPress &&
			ke->key() == Qt::Key_Pause)
	{
		stopTest();
		return false;
	}

	///////////////////////////////////////////////////////
	// uniquely identify the active widget:
	// walk up the QObject tree and collect all names of QWidgets
	///////////////////////////////////////////////////////
	
	// take the sending object
 	QObject* o = obj;
	QObject* parent = 0;
	x_ = y_ = 0;

	// for mouse events: take widget under the mouse cursor
	if (me != 0) 
	{
		widget_ = qApp->widgetAt(me->globalPos());
		if (widget_ == 0) return false;
//.........这里部分代码省略.........
开发者ID:HeyJJ,项目名称:ball,代码行数:101,代码来源:testFramework.C


注:本文中的QShortcutEvent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。