本文整理汇总了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)));
}
示例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;
}
}
}
示例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);
}
示例4: shortcutTriggered
void ActionManagerPrivate::shortcutTriggered()
{
QShortcut *sc = qobject_cast<QShortcut *>(QObject::sender());
if (sc)
showShortcutPopup(sc->key().toString());
}
示例5: keyPressed
void ChannelSelect::keyPressed()
{
QShortcut *tmp = qobject_cast<QShortcut *>(sender());
process(tmp->key().toString().toInt());
}