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


C++ QShortcutEvent::shortcutId方法代码示例

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


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

示例1: event

/*!\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

/*!
    \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

示例5: event

/*! \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

示例6: eventFilter


//.........这里部分代码省略.........
				{
					name = ascii((**actions.begin()).objectName());
				}
			}
		}
		else
		{
			// if a parent has more childs with the same name: add a suffix with the number
			if (!parent) parent = o->parent();
			if (parent != 0)
			{
				QList<QWidget*> childs = parent->findChildren<QWidget*>(name.c_str());
				if (childs.size() > 1)
				{
					Position pos = 0;
					QList<QWidget*>::iterator wit = childs.begin();
					for (; wit != childs.end(); wit++)
					{
						if (*wit == o)
						{
							name += "#";
							name += String(pos);
							break;
						}

						pos++;
					}
				}
			}
		}

		if (name != "") names = name + "|" + names;
		o = o->parent();
	}


	String event_string;
	event_string += String((int)e->type()) + "|";
	event_string += String(getMainControl()->isBusy()) + "|";

	if (me != 0)
	{
		if (me->button() == Qt::NoButton &&
				!switch_move->isChecked() && 
				me->type() == QEvent::MouseMove &&	
				widget_ == last_widget_)
		{
			return false;
		}

 		last_widget_ = widget_;

		event_string += String((int)MOUSE) + "|";
		event_string += String((int) me->modifiers()) + "|";
		event_string += String((int) me->button()) + "|";
		event_string += String((int) me->buttons()) + "|";
		event_string += String(x_) + "|";
		event_string += String(y_) + "|";

		// prevent mouse move events with same position
		if (event_string == last_event_string_ &&
				names 			 == last_names_)
		{
			return false;
		}
	}
	else if (ke != 0)
	{
		// prevent accepting key events that are resend further up in the widget tree
		if (timer_.getClockTime() < 0.01) return false;

		int m = (int) ke->modifiers();
		// sometimes Qt sends nonsense Key messages
		if (m > (int)(Qt::AltModifier | Qt::ControlModifier | Qt::ShiftModifier)) return false;

		event_string += String((int)KEY) + "|";
		event_string += String(m);
		event_string += "|";
		event_string += String(ke->key()) + "|";
	}
	else if (se != 0)
	{
		event_string += String((int)SHORTCUT) + "|";
		event_string += String(se->shortcutId()) + "|";
		event_string += ascii(se->key().toString()) + "|";
	}

	float time = timer_.getClockTime();
	timer_.reset();

	outfile_ << "I°"
					 << time << "°"
					 << names << "°"
					 << event_string << std::endl;

	last_event_string_ = event_string;
	last_names_  			 = names;

	return false;
}
开发者ID:HeyJJ,项目名称:ball,代码行数:101,代码来源:testFramework.C


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