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


C++ QShortcut::key方法代码示例

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


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

示例1: createShortcuts

void RichTextLineEdit::createShortcuts()
{
    QShortcut *boldShortcut = new QShortcut(QKeySequence::Bold,
            this, SLOT(toggleBold()));
    QShortcut *italicShortcut = new QShortcut(QKeySequence::Italic,
            this, SLOT(toggleItalic()));

    setToolTip(tr("<p>Use %1 to toggle bold, %2 to toggle italic, "
                  "and the context menu for color and other effects.")
            .arg(boldShortcut->key().toString(
                 QKeySequence::NativeText))
            .arg(italicShortcut->key().toString(
                 QKeySequence::NativeText)));
}
开发者ID:jhj,项目名称:aqp-qt5,代码行数:14,代码来源:richtextlineedit.cpp

示例2: freeAccelleratorKeySequence

void KviMainWindow::freeAccelleratorKeySequence(QString & key)
{
	QKeySequence kS(key);
	for(QShortcut * pS = m_pAccellerators->first(); pS; pS = m_pAccellerators->next())
	{
		if(pS->key() == kS)
		{
			m_pAccellerators->removeRef(pS);
			return;
		}
	}
}
开发者ID:un1versal,项目名称:KVIrc,代码行数:12,代码来源:KviMainWindow.cpp

示例3: onShortcutJumpToTab

// Switch to nth tab when Alt+n or Ctrl+n is pressed
void MainWindow::onShortcutJumpToTab() {
  QShortcut* shortcut = reinterpret_cast<QShortcut*>(sender());
  QKeySequence seq = shortcut->key();
  int keyValue = seq[0];
  // See the source code of QKeySequence and refer to the method:
  // QString QKeySequencePrivate::encodeString(int key, QKeySequence::SequenceFormat format).
  // Then we know how to test if a key sequence contains a modifier.
  // It's a shame that Qt has no API for this task.

  if((keyValue & Qt::ALT) == Qt::ALT) // test if we have Alt key pressed
    keyValue -= Qt::ALT;
  else if((keyValue & Qt::CTRL) == Qt::CTRL) // test if we have Ctrl key pressed
    keyValue -= Qt::CTRL;

  // now keyValue should contains '0' - '9' only
  int index;
  if(keyValue == '0')
    index = 9;
  else
    index = keyValue - '1';
  if(index < ui.tabBar->count())
    ui.tabBar->setCurrentIndex(index);
}
开发者ID:WL-hohoho,项目名称:pcmanfm-qt,代码行数:24,代码来源:mainwindow.cpp

示例4: shortcutTriggered

void ActionManagerPrivate::shortcutTriggered()
{
    QShortcut *sc = qobject_cast<QShortcut *>(QObject::sender());
    if (sc)
        showShortcutPopup(sc->key().toString());
}
开发者ID:edwardZhang,项目名称:qt-creator,代码行数:6,代码来源:actionmanager.cpp

示例5: keyPressed

void ChannelSelect::keyPressed()
{
    QShortcut *tmp = qobject_cast<QShortcut *>(sender());
    process(tmp->key().toString().toInt());
}
开发者ID:RaoulVolfoni,项目名称:tano,代码行数:5,代码来源:ChannelSelect.cpp


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