本文整理汇总了C++中QShortcut类的典型用法代码示例。如果您正苦于以下问题:C++ QShortcut类的具体用法?C++ QShortcut怎么用?C++ QShortcut使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QShortcut类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: resize
void NotepadForm::setupUi()
{
resize(680, 450);
QVBoxLayout* lay = new QVBoxLayout(this);
lay->setSpacing(5);
lay->setContentsMargins(5, 5, 5, 5);
m_board = new QPlainTextEdit(this);
m_board->setAcceptDrops(false);
m_board->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
m_board->setTabChangesFocus(false);
m_board->setUndoRedoEnabled(true);
m_board->setTextInteractionFlags(Qt::TextEditorInteraction);
lay->addWidget(m_board);
setWindowTitle(tr("Notepad"));
QMetaObject::connectSlotsByName(this);
QShortcut* n = new QShortcut(QKeySequence(Qt::Key_Tab+Qt::CTRL), this);
QShortcut* l = new QShortcut(QKeySequence(Qt::Key_Tab+Qt::CTRL+Qt::SHIFT), this);
n->setObjectName("n");
l->setObjectName("l");
connect(n, SIGNAL(activated()), this, SLOT(jumptab()));
connect(l, SIGNAL(activated()), this, SLOT(jumptab()));
}
示例2: QWidget
Cleps_VidPlayer::Cleps_VidPlayer(QWidget *parent)
: QWidget(parent)
{
videoWidget = new QVideoWidget(this);
videoWidget->setContextMenuPolicy(Qt::CustomContextMenu);
videoWidget->setAspectRatioMode(Qt::IgnoreAspectRatio);
QBoxLayout *mreLayout = new QHBoxLayout;
mreLayout->setMargin(0);
mreLayout->setSpacing(0);
QBoxLayout *layout = new QVBoxLayout;
layout->addWidget(videoWidget);
layout->addLayout(mreLayout);
setLayout(layout);
QShortcut *fll = new QShortcut(QKeySequence(Qt::Key_F11), videoWidget);
fll->setContext(Qt::ApplicationShortcut);
QShortcut *fllve = new QShortcut(QKeySequence(Qt::Key_Escape), videoWidget);
fllve->setContext(Qt::ApplicationShortcut);
connect(fll,SIGNAL(activated()),this,SLOT(fullScreen()));
connect(fllve,SIGNAL(activated()),this,SLOT(exitFullScreen()));
connect(videoWidget, SIGNAL(customContextMenuRequested(QPoint)),this, SLOT(context(QPoint)));
}
示例3: sipReleaseType
static PyObject *meth_QShortcut_setKey(PyObject *sipSelf, PyObject *sipArgs)
{
PyObject *sipParseErr = NULL;
{
const QKeySequence* a0;
int a0State = 0;
QShortcut *sipCpp;
if (sipParseArgs(&sipParseErr, sipArgs, "BJ1", &sipSelf, sipType_QShortcut, &sipCpp, sipType_QKeySequence, &a0, &a0State))
{
Py_BEGIN_ALLOW_THREADS
sipCpp->setKey(*a0);
Py_END_ALLOW_THREADS
sipReleaseType(const_cast<QKeySequence *>(a0),sipType_QKeySequence,a0State);
Py_INCREF(Py_None);
return Py_None;
}
}
/* Raise an exception if the arguments couldn't be parsed. */
sipNoMethod(sipParseErr, sipName_QShortcut, sipName_setKey, doc_QShortcut_setKey);
return NULL;
}
示例4: CutterDockWidget
ImportsWidget::ImportsWidget(MainWindow *main, QAction *action) :
CutterDockWidget(main, action),
ui(new Ui::ImportsWidget),
importsModel(new ImportsModel(&imports, this)),
importsProxyModel(new ImportsProxyModel(importsModel, this))
{
ui->setupUi(this);
ui->importsTreeView->setModel(importsProxyModel);
ui->importsTreeView->sortByColumn(ImportsModel::NameColumn, Qt::AscendingOrder);
// Ctrl-F to show/hide the filter entry
QShortcut *searchShortcut = new QShortcut(QKeySequence::Find, this);
connect(searchShortcut, &QShortcut::activated, ui->quickFilterView, &QuickFilterView::showFilter);
searchShortcut->setContext(Qt::WidgetWithChildrenShortcut);
// Esc to clear the filter entry
QShortcut *clearShortcut = new QShortcut(QKeySequence(Qt::Key_Escape), this);
connect(clearShortcut, &QShortcut::activated, ui->quickFilterView, &QuickFilterView::clearFilter);
clearShortcut->setContext(Qt::WidgetWithChildrenShortcut);
connect(ui->quickFilterView, SIGNAL(filterTextChanged(const QString &)),
importsProxyModel, SLOT(setFilterWildcard(const QString &)));
connect(ui->quickFilterView, SIGNAL(filterClosed()), ui->importsTreeView, SLOT(setFocus()));
setScrollMode();
connect(Core(), SIGNAL(refreshAll()), this, SLOT(refreshImports()));
}
示例5: QShortcut
void Window::shortcut(QKeySequence key, const char * execThis)
{
QShortcut *shortcut = new QShortcut(key, this);
shortcut->setContext(Qt::ApplicationShortcut);
connect(shortcut, SIGNAL(activated()), this, execThis);
wxyz[0] = wxyz[1] = wxyz[2] = wxyz[3] = 0;
}
示例6: QDialog
PropertiesDialog::PropertiesDialog(const QString &kind,
Object *object,
QUndoStack *undoStack,
QWidget *parent):
QDialog(parent),
mUndoStack(undoStack),
mObject(object),
mKind(kind)
{
mUi = new Ui::PropertiesDialog;
mUi->setupUi(this);
mModel = new PropertiesModel(this);
mModel->setProperties(mObject->properties());
mUi->propertiesView->setModel(mModel);
// Delete selected properties when the delete key is pressed
QShortcut *deleteShortcut = new QShortcut(QKeySequence::Delete,
mUi->propertiesView);
deleteShortcut->setContext(Qt::WidgetShortcut);
connect(deleteShortcut, SIGNAL(activated()),
this, SLOT(deleteSelectedProperties()));
setWindowTitle(tr("%1 Properties").arg(mKind));
}
示例7: connect
void MainWindow::addTeam()
{
int tc = teams.count();
if (tc) {
teams.last()->button->disconnect();
teams.last()->button->setIcon(QIcon(":/images/images/remove.png"));
connect(teams.last()->button, SIGNAL(clicked()),
this, SLOT(removeTeam()));
}
team *n = new team;
n->number = new QLabel;
n->number->setText(QString::number(teams.count() + 1) + ")");
n->name = new QLineEdit;
n->button = new QToolButton;
teams.append(n);
QGridLayout *layout = static_cast <QGridLayout *> (ui->list->layout());
layout->addWidget(n->number, lli, 0);
connect(n->name, SIGNAL(returnPressed()), this, SLOT(drawCouples()));
QShortcut *sh = new QShortcut(QKeySequence("Ctrl+Return"), n->name);
sh->setContext(Qt::WidgetShortcut);
connect(sh, SIGNAL(activated()), this, SLOT(ctrlEnterPressed()));
QShortcut *sh1 = new QShortcut(QKeySequence("Tab"), n->name);
sh1->setContext(Qt::WidgetShortcut);
connect(sh1, SIGNAL(activated()), this, SLOT(tabPressed()));
QShortcut *sh2 = new QShortcut(QKeySequence("Shift+Tab"), n->name);
sh2->setContext(Qt::WidgetShortcut);
connect(sh2, SIGNAL(activated()), this, SLOT(shiftTabPressed()));
layout->addWidget(n->name, lli, 1);
n->button->setIcon(QIcon(":/images/images/add.png"));
connect(n->button, SIGNAL(clicked()), this, SLOT(addTeam()));
layout->addWidget(n->button, lli, 2);
++lli;
n->name->setFocus();
}
示例8: foreach
void ModeManager::objectAdded(QObject *obj)
{
IMode *mode = Aggregation::query<IMode>(obj);
if (!mode)
return;
m_mainWindow->addContextObject(mode);
// Count the number of modes with a higher priority
int index = 0;
foreach (const IMode *m, m_modes)
if (m->priority() > mode->priority())
++index;
m_modes.insert(index, mode);
m_modeStack->insertTab(index, mode->widget(), mode->icon(), mode->name());
// Register mode shortcut
ActionManager *am = m_mainWindow->actionManager();
const QString shortcutId = QLatin1String("GCS.Mode.") + mode->uniqueModeName();
QShortcut *shortcut = new QShortcut(m_mainWindow);
shortcut->setWhatsThis(tr("Switch to %1 mode").arg(mode->name()));
Command *cmd = am->registerShortcut(shortcut, shortcutId, QList<int>() << Constants::C_GLOBAL_ID);
m_modeShortcuts.insert(index, cmd);
connect(cmd, SIGNAL(keySequenceChanged()), this, SLOT(updateModeToolTip()));
setDefaultKeyshortcuts();
m_signalMapper->setMapping(shortcut, mode->uniqueModeName());
connect(shortcut, SIGNAL(activated()), m_signalMapper, SLOT(map()));
}
示例9: QShortcut
void BaseForm::bindSelect(QComboBox* b, qint32 i, qint32 k)
{
QShortcut* s = new QShortcut(QKeySequence(k), this);
s->setProperty(PROP_TARG, qVariantFromValue((void*)b));
s->setObjectName(QString::number(i));
connect(s, SIGNAL(activated()), this, SLOT(select()));
}
示例10: QShortcut
void MainWindow::setupShortcuts()
{
QShortcut *focusSearch = new QShortcut(QKeySequence("Ctrl+K"), this);
focusSearch->setContext(Qt::ApplicationShortcut);
connect(focusSearch, &QShortcut::activated, [=]() {
ui->lineEdit->setFocus();
});
}
示例11: QLabel
OverwriteWidget::OverwriteWidget(QWidget *parent)
: QLabel(parent)
{
QShortcut *s = new QShortcut(Qt::Key_Insert, this);
s->setContext(Qt::ApplicationShortcut);
connect(s, SIGNAL(activated()), SLOT(changeOverwriteMode()));
setText(tr("OVR"));
setEnabled(false);
}
示例12: QShortcut
void WebkitShow::setupInspector()
{
QWebPage* webpage = view->page();
webpage->settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
webInspector->setPage(webpage);
QShortcut* shortCut = new QShortcut(this);
shortCut->setKey(Qt::Key_F12);
connect(shortCut, SIGNAL(activated()), this, SLOT(toggleInspector()));
}
示例13: QShortcut
QShortcut *ConvertAccelerator( wxAcceleratorEntry *e, QWidget *parent )
{
// TODO: Not all keys have the same string representation in wx and qt
QShortcut *s = new QShortcut( wxQtConvertString( e->ToString() ), parent );
// Set a property to save wx Command to send when activated
s->setProperty( "wxQt_Command", e->GetCommand() );
return s;
}
示例14: QDeclarativeView
GreeterWindow::GreeterWindow(QWidget *parent)
: QDeclarativeView(parent),
m_greeter(new GreeterWrapper(this))
{
setResizeMode(QDeclarativeView::SizeRootObjectToView);
KDeclarative kdeclarative;
kdeclarative.setDeclarativeEngine(engine());
kdeclarative.initialize();
//binds things like kconfig and icons
kdeclarative.setupBindings();
KConfig config(LIGHTDM_CONFIG_DIR "/lightdm-kde-greeter.conf");
KConfigGroup configGroup = config.group("greeter");
QString theme = configGroup.readEntry("theme-name", "userbar");
QStringList dirs = KGlobal::dirs()->findDirs("appdata", "themes/");
Plasma::PackageStructure::Ptr packageStructure(new LightDMPackageStructure(this));
Plasma::Package package(dirs.last() + "/" + theme, packageStructure);
if (!package.isValid()) {
kError() << theme << " is not a valid theme. Falling back to \"userbar\" theme.";
package = Plasma::Package(dirs.last() + "/" + "userbar", packageStructure);
}
if (!package.isValid()) {
kFatal() << "Cannot find QML file for \"userbar\" theme. Something is wrong with this installation. Aborting.";
}
KGlobal::locale()->insertCatalog("lightdm_theme_" + theme);
rootContext()->setContextProperty("config", new ConfigWrapper(package.filePath("configfile"), this));
rootContext()->setContextProperty("greeter", m_greeter);
setSource(package.filePath("mainscript"));
// Prevent screen flickering when the greeter starts up. This really needs to be sorted out in QML/Qt...
setAttribute(Qt::WA_OpaquePaintEvent);
setAttribute(Qt::WA_NoSystemBackground);
// Shortcut to take a screenshot of the screen. Handy because it is not
// possible to take a screenshot of the greeter in test mode without
// including the cursor.
QShortcut* cut = new QShortcut(this);
cut->setKey(Qt::CTRL + Qt::ALT + Qt::Key_S);
connect(cut, SIGNAL(activated()), SLOT(screenshot()));
connect(m_greeter, SIGNAL(aboutToLogin()), SLOT(setRootImage()));
QRect screen = QApplication::desktop()->rect();
setGeometry(screen);
new PowerManagement(this);
}
示例15: QShortcut
void Toerstein::createShortcuts(void)
{
QShortcut *shortcut;
/* In QMenuBar shortcuts won't work if menuBar is not visible,
* so we'll add them separately here
*/
/* Shortcuts to File-menu */
shortcut = new QShortcut(QKeySequence(tr("Ctrl+T", "File|New Tab")),this,SLOT(createNewTab()));
shortcut->setAutoRepeat(false);
shortcut = new QShortcut(QKeySequence(tr("Ctrl+N", "File|New File")),this,SLOT(createNewFile()));
shortcut->setAutoRepeat(false);
shortcut = new QShortcut(QKeySequence(tr("Ctrl+O", "File|Open File")),this,SLOT(open()));
shortcut->setAutoRepeat(false);
shortcut = new QShortcut(QKeySequence(tr("Ctrl+P", "File|Enter File Path") ),this,SLOT(search()));
shortcut->setAutoRepeat(false);
shortcut = new QShortcut(QKeySequence(tr("Ctrl+S", "File|Save File") ),this,SLOT(save()));
shortcut->setAutoRepeat(false);
shortcut = new QShortcut(QKeySequence(tr("Ctrl+W", "File|Close File") ),this,SLOT(closeFile()));
shortcut->setAutoRepeat(false);
shortcut = new QShortcut(QKeySequence(tr("Ctrl+Q", "File|Quit")),this,SLOT(close()));
shortcut->setAutoRepeat(false);
/* Shortcuts to View-menu */
shortcut = new QShortcut(QKeySequence(tr("Ctrl+D", "Toggle Diff View|Quit")),this,SLOT(toggleViewMode()));
shortcut->setAutoRepeat(false);
}