本文整理汇总了C++中QAction::setShortcuts方法的典型用法代码示例。如果您正苦于以下问题:C++ QAction::setShortcuts方法的具体用法?C++ QAction::setShortcuts怎么用?C++ QAction::setShortcuts使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QAction
的用法示例。
在下文中一共展示了QAction::setShortcuts方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
void TextureViewer::init()
{
control=0;
shaderName=0;
setMenuBar(new QMenuBar);
QMenu *fileMenu = menuBar()->addMenu(tr("&File"));
//Open action
QAction *openAct = new QAction( tr("&Open"), this );
openAct->setShortcuts(QKeySequence::Open);
openAct->setStatusTip(tr("Open"));
connect(openAct, SIGNAL(triggered()), this, SLOT(openFile()));
QAction *createControlsAct = new QAction( tr("&Controls"), this );
createControlsAct->setStatusTip(tr("Create Controls"));
connect(createControlsAct, SIGNAL(triggered()), this, SLOT(createControls()));
//Quit action
QAction *quitAct = new QAction( tr("&Quit"), this );
quitAct->setShortcuts(QKeySequence::Quit);
quitAct->setStatusTip(tr("Quit"));
connect(quitAct, SIGNAL(triggered()), this, SLOT(close()));
fileMenu->addAction(openAct);
fileMenu->addAction(createControlsAct);
fileMenu->addAction(quitAct);
}
示例2: QMenu
QMenu *BrowserWindow::createFileMenu(TabWidget *tabWidget)
{
QMenu *fileMenu = new QMenu(tr("&File"));
fileMenu->addAction(tr("&New Window"), this, &BrowserWindow::handleNewWindowTriggered, QKeySequence::New);
QAction *newTabAction = new QAction(QIcon(QLatin1String(":addtab.png")), tr("New &Tab"), this);
newTabAction->setShortcuts(QKeySequence::AddTab);
newTabAction->setIconVisibleInMenu(false);
connect(newTabAction, &QAction::triggered, tabWidget, &TabWidget::createTab);
fileMenu->addAction(newTabAction);
fileMenu->addAction(tr("&Open File..."), this, &BrowserWindow::handleFileOpenTriggered, QKeySequence::Open);
fileMenu->addSeparator();
QAction *closeTabAction = new QAction(QIcon(QLatin1String(":closetab.png")), tr("&Close Tab"), this);
closeTabAction->setShortcuts(QKeySequence::Close);
closeTabAction->setIconVisibleInMenu(false);
connect(closeTabAction, &QAction::triggered, [tabWidget]() {
tabWidget->closeTab(tabWidget->currentIndex());
});
fileMenu->addAction(closeTabAction);
QAction *closeAction = new QAction(tr("&Quit"),this);
closeAction->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_Q));
connect(closeAction, &QAction::triggered, this, &QWidget::close);
fileMenu->addAction(closeAction);
connect(fileMenu, &QMenu::aboutToShow, [closeAction]() {
if (Browser::instance().windows().count() == 1)
closeAction->setText(tr("&Quit"));
else
closeAction->setText(tr("&Close Window"));
});
return fileMenu;
}
示例3: menuBar
//MainWindow::MainWindow(QWidget *parent):QWidget(parent)
MainWindow::MainWindow() {
this->resize(640,480);
QMenu *fileMenu = menuBar()->addMenu(tr("&File"));
QAction *newFileAction = new QAction(tr("&New"),this);
newFileAction->setShortcuts(QKeySequence::New);
connect(newFileAction, SIGNAL(triggered()), this, SLOT(newFile()));
fileMenu->addAction(newFileAction);
QAction *openAction = new QAction(tr("&Open"),this);
openAction->setShortcuts(QKeySequence::Open);
// connect(newAct, SIGNAL(triggered()), this, SLOT(newFile()));
connect(openAction, SIGNAL(triggered()), this, SLOT(open()));
fileMenu->addAction(openAction);
QAction *saveAsAction = new QAction(tr("&Save As..."),this);
saveAsAction->setShortcuts(QKeySequence::SaveAs);
connect(saveAsAction, SIGNAL(triggered()), this, SLOT(saveAs()));
fileMenu->addAction(saveAsAction);
// ShapeContainer *cont = new ShapeContainer();
// cont->addCircle(150,150,75,100,122,122);
// cont->setSelected(true);
// this->shapeContainers.push_back(cont);
// this->setCurrentContainer(cont);
}
示例4: QMenu
MainWindow::MainWindow()
{
QMenu *fileMenu = new QMenu(tr("&File"), this);
QAction *openAction = fileMenu->addAction(tr("&Open..."));
openAction->setShortcuts(QKeySequence::Open);
QAction *saveAction = fileMenu->addAction(tr("&Save As..."));
saveAction->setShortcuts(QKeySequence::SaveAs);
QAction *quitAction = fileMenu->addAction(tr("E&xit"));
quitAction->setShortcuts(QKeySequence::Quit);
setupModel();
setupViews();
connect(openAction, SIGNAL(triggered()), this, SLOT(openFile()));
connect(saveAction, SIGNAL(triggered()), this, SLOT(saveFile()));
connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
menuBar()->addMenu(fileMenu);
statusBar();
openFile(":/Charts/qtdata.cht");
setWindowTitle(tr("Chart"));
resize(870, 550);
}
示例5: layout
LevelEditorWindow::LevelEditorWindow()
{
//QHBoxLayout *mainLayout = new QHBoxLayout();
//setLayout( mainLayout );
/*DebugMenus::menu = new DebugMenus();
DebugMenus::menu->setVisible( false );
DebugMenus::inject( layout() );*/
handle = new LevelEditorHandle();
setCentralWidget( handle );
QMenu* fileMenu = menuBar()->addMenu("File");
QAction* action;
fileMenu->addAction(action = new QAction("Load Wavefront (.obj) File", this));
action->setShortcut(QKeySequence::New);
connect(action, SIGNAL(triggered()), this, SLOT(loadObj()));
fileMenu->addAction(action = new QAction("Save Level Binary", this));
action->setShortcuts(QKeySequence::Save);
connect(action, SIGNAL(triggered()), this, SLOT(saveNative()));
fileMenu->addAction(action = new QAction("Save Level Binary File as..", this));
action->setShortcuts(QKeySequence::SaveAs);
connect(action, SIGNAL(triggered()), this, SLOT(saveNativeAs()));
fileMenu->addAction(action = new QAction("Load Level Binary", this));
action->setShortcuts(QKeySequence::Open);
connect(action, SIGNAL(triggered()), this, SLOT(loadNative()));
}
示例6: createActions
void MainWindow::createActions()
{
QMenu *fileMenu = menuBar()->addMenu(tr("&File"));
QToolBar *fileToolBar = addToolBar(tr("File"));
const QIcon newIcon = QIcon::fromTheme("document-new", QIcon(":/images/new.png"));
QAction *newLetterAct = new QAction(newIcon, tr("&New Letter"), this);
newLetterAct->setShortcuts(QKeySequence::New);
newLetterAct->setStatusTip(tr("Create a new form letter"));
connect(newLetterAct, &QAction::triggered, this, &MainWindow::newLetter);
fileMenu->addAction(newLetterAct);
fileToolBar->addAction(newLetterAct);
const QIcon saveIcon = QIcon::fromTheme("document-save", QIcon(":/images/save.png"));
QAction *saveAct = new QAction(saveIcon, tr("&Save..."), this);
saveAct->setShortcuts(QKeySequence::Save);
saveAct->setStatusTip(tr("Save the current form letter"));
connect(saveAct, &QAction::triggered, this, &MainWindow::save);
fileMenu->addAction(saveAct);
fileToolBar->addAction(saveAct);
const QIcon printIcon = QIcon::fromTheme("document-print", QIcon(":/images/print.png"));
QAction *printAct = new QAction(printIcon, tr("&Print..."), this);
printAct->setShortcuts(QKeySequence::Print);
printAct->setStatusTip(tr("Print the current form letter"));
connect(printAct, &QAction::triggered, this, &MainWindow::print);
fileMenu->addAction(printAct);
fileToolBar->addAction(printAct);
fileMenu->addSeparator();
QAction *quitAct = fileMenu->addAction(tr("&Quit"), this, &QWidget::close);
quitAct->setShortcuts(QKeySequence::Quit);
quitAct->setStatusTip(tr("Quit the application"));
QMenu *editMenu = menuBar()->addMenu(tr("&Edit"));
QToolBar *editToolBar = addToolBar(tr("Edit"));
const QIcon undoIcon = QIcon::fromTheme("edit-undo", QIcon(":/images/undo.png"));
QAction *undoAct = new QAction(undoIcon, tr("&Undo"), this);
undoAct->setShortcuts(QKeySequence::Undo);
undoAct->setStatusTip(tr("Undo the last editing action"));
connect(undoAct, &QAction::triggered, this, &MainWindow::undo);
editMenu->addAction(undoAct);
editToolBar->addAction(undoAct);
viewMenu = menuBar()->addMenu(tr("&View"));
menuBar()->addSeparator();
QMenu *helpMenu = menuBar()->addMenu(tr("&Help"));
QAction *aboutAct = helpMenu->addAction(tr("&About"), this, &MainWindow::about);
aboutAct->setStatusTip(tr("Show the application's About box"));
QAction *aboutQtAct = helpMenu->addAction(tr("About &Qt"), qApp, &QApplication::aboutQt);
aboutQtAct->setStatusTip(tr("Show the Qt library's About box"));
}
示例7: init
void Logger::init(QTreeWidget* o, QCheckBox* w, QPlainTextEdit* d)
{
m_cmlog.clear();
m_cmtxt.clear();
if (m_treeOut)
m_treeOut->disconnect(this);
if (m_textOut)
m_textOut->disconnect(this);
if (m_chkWrite)
m_chkWrite->disconnect(this);
m_treeOut = o;
m_textOut = d;
m_chkWrite = w;
if (m_treeOut && m_textOut && m_chkWrite)
{
QList<QKeySequence> ks;
ks << QKeySequence(Qt::CTRL + Qt::Key_D);
QAction* copy = new QAction(tr("Copy"), this);
copy->setShortcuts(QKeySequence::Copy);
connect(copy, SIGNAL(triggered()), this, SLOT(copy()));
QAction* clear = new QAction(tr("Clear"), this);
clear->setShortcuts(ks);
connect(clear, SIGNAL(triggered()), this, SIGNAL(clearLog()));
QAction* all = new QAction(tr("Select All"), this);
all->setShortcuts(QKeySequence::SelectAll);
connect(all, SIGNAL(triggered()), m_textOut, SLOT(selectAll()));
m_cmlog.addAction(copy);
m_cmlog.addSeparator();
m_cmlog.addAction(clear);
m_cmtxt.addAction(copy);
m_cmtxt.addSeparator();
m_cmtxt.addAction(all);
QPalette pal = m_textOut->palette();
pal.setBrush(QPalette::Base, m_treeOut->palette().brush(QPalette::Window));
m_textOut->setPalette(pal);
m_treeOut->setContextMenuPolicy(Qt::CustomContextMenu);
connect(m_treeOut, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(ctxmenu(const QPoint&)));
connect(m_treeOut, SIGNAL(itemSelectionChanged()), this, SLOT(syncOutput()));
m_textOut->setContextMenuPolicy(Qt::CustomContextMenu);
connect(m_textOut, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(ctxmenu(const QPoint&)));
}
示例8: setupMenus
void MainWindow::setupMenus()
{
QMenu *fileMenu = menuBar()->addMenu(tr("&File"));
QAction *openAction = fileMenu->addAction(tr("&Open..."), this, &MainWindow::openImage);
openAction->setShortcuts(QKeySequence::Open);
QAction *exitAction = fileMenu->addAction(tr("E&xit"), qApp, &QCoreApplication::quit);
exitAction->setShortcuts(QKeySequence::Quit);
QMenu *gameMenu = menuBar()->addMenu(tr("&Game"));
gameMenu->addAction(tr("&Restart"), this, &MainWindow::setupPuzzle);
}
示例9: createContextMenuQStudyTreeWidget
void QInputOutputDicomdirWidget::createContextMenuQStudyTreeWidget()
{
QAction *action;
action = m_contextMenuQStudyTreeWidget.addAction(QIcon(":/images/view.png"), tr("&View"), this, SLOT(view()));
action->setShortcuts(ShortcutManager::getShortcuts(Shortcuts::ViewSelectedStudies));
(void) new QShortcut(action->shortcut(), this, SLOT(view()));
action = m_contextMenuQStudyTreeWidget.addAction(QIcon(":/images/retrieve.png"), tr("&Import"), this, SLOT(retrieveSelectedStudies()));
action->setShortcuts(ShortcutManager::getShortcuts(Shortcuts::ImportToLocalDatabaseSelectedDICOMDIRStudies));
(void) new QShortcut(action->shortcut(), this, SLOT(retrieveSelectedStudies()));
// Especifiquem que es el menu del dicomdir
m_studyTreeWidget->setContextMenu(& m_contextMenuQStudyTreeWidget);
}
示例10: createMenuBar
void MainWindow::createMenuBar()
{
QAction *addAction = new QAction(tr("&Add album..."), this);
QAction *deleteAction = new QAction(tr("&Delete album..."), this);
QAction *quitAction = new QAction(tr("&Quit"), this);
QAction *aboutAction = new QAction(tr("&About"), this);
QAction *aboutQtAction = new QAction(tr("About &Qt"), this);
addAction->setShortcut(tr("Ctrl+A"));
deleteAction->setShortcut(tr("Ctrl+D"));
quitAction->setShortcuts(QKeySequence::Quit);
QMenu *fileMenu = menuBar()->addMenu(tr("&File"));
fileMenu->addAction(addAction);
fileMenu->addAction(deleteAction);
fileMenu->addSeparator();
fileMenu->addAction(quitAction);
QMenu *helpMenu = menuBar()->addMenu(tr("&Help"));
helpMenu->addAction(aboutAction);
helpMenu->addAction(aboutQtAction);
connect(addAction, SIGNAL(triggered(bool)), this, SLOT(addAlbum()));
connect(deleteAction, SIGNAL(triggered(bool)), this, SLOT(deleteAlbum()));
connect(quitAction, SIGNAL(triggered(bool)), this, SLOT(close()));
connect(aboutAction, SIGNAL(triggered(bool)), this, SLOT(about()));
connect(aboutQtAction, SIGNAL(triggered(bool)), qApp, SLOT(aboutQt()));
}
示例11: settings
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent)
{
QSettings settings ("binaervarianz.de", "FollowMe");
restoreGeometry(settings.value("geometry", saveGeometry()).toByteArray());
restoreState(settings.value("windowState", saveState()).toByteArray());
mfilelist= new FMFileList(parent);
model = new QFileSystemModel;
QString extPath = settings.value("extPath",QDir::homePath()).toString();
model->setRootPath(extPath );
list = new QTreeView(this);
updateFileBrowser(extPath);
setCentralWidget(list);
QAction *prefAct = new QAction(tr("&Preferences..."), this);
prefAct->setShortcuts(QKeySequence::Preferences);
prefAct->setStatusTip(tr("Open preference pane"));
connect(prefAct, SIGNAL(triggered()), this, SLOT(openPreferences()));
QMenuBar* menu = menuBar();
QMenu* fileMenu = menu->addMenu(tr("&File"));
fileMenu->addAction(prefAct);
ui = new PreferenceDialog2(this);
}
示例12: saveShortcuts
void PropertiesDialog::saveShortcuts()
{
QMap<QString, QAction*> actions = QTerminalApp::Instance()->getWindowList()[0]->leaseActions();
QList< QString > shortcutKeys = actions.keys();
int shortcutCount = shortcutKeys.count();
shortcutsWidget->setRowCount( shortcutCount );
for( int x=0; x < shortcutCount; x++ )
{
QString keyValue = shortcutKeys.at(x);
QAction *keyAction = actions[keyValue];
QTableWidgetItem *item = shortcutsWidget->item(x, 1);
QKeySequence sequence = QKeySequence(item->text());
QString sequenceString = sequence.toString();
QList<QKeySequence> shortcuts;
const auto sequences = item->text().split(QLatin1Char('|'));
for (const QKeySequence& sequenceString : sequences)
shortcuts.append(QKeySequence(sequenceString));
keyAction->setShortcuts(shortcuts);
}
Properties::Instance()->saveSettings();
}
示例13: loadFromConfig
void ActionsEditor::loadFromConfig(QObject *o, QSettings *set) {
qDebug("ActionsEditor::loadFromConfig");
set->beginGroup("actions");
QAction *action;
QString accelText;
QList<QAction *> actions = o->findChildren<QAction *>();
for (int n=0; n < actions.count(); n++) {
action = static_cast<QAction*> (actions[n]);
if (!action->objectName().isEmpty() && !action->inherits("QWidgetAction")) {
#if USE_MULTIPLE_SHORTCUTS
QString current = shortcutsToString(action->shortcuts());
accelText = set->value(action->objectName(), current).toString();
action->setShortcuts( stringToShortcuts( accelText ) );
#else
accelText = set->value(action->objectName(), action->shortcut().toString()).toString();
action->setShortcut(QKeySequence(accelText));
#endif
}
}
set->endGroup();
}
示例14: QAction
MainWindow::MainWindow()
{
QAction *exitAct = new QAction(tr("E&xit"), this);
exitAct->setShortcuts(QKeySequence::Quit);
connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));
QMenu *fileMenu = menuBar()->addMenu(tr("&File"));
fileMenu->addSeparator();
fileMenu->addAction(exitAct);
columnsMenu = menuBar()->addMenu(tr("&Columns"));
connect(columnsMenu, SIGNAL(aboutToShow()), this, SLOT(showColumnsMenu()));
model = new PeerDrive::FolderModel(this);
connect(model, SIGNAL(rowsInserted(QModelIndex,int,int)), this,
SLOT(modelRowsInserted(QModelIndex,int,int)));
connect(model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this,
SLOT(modelDataChanged(QModelIndex,QModelIndex)));
connect(model, SIGNAL(modelReset()), this, SLOT(modelReset()));
treeView = new QTreeView;
treeView->setModel(model);
treeView->sortByColumn(0, Qt::AscendingOrder);
treeView->setSortingEnabled(true);
connect(treeView, SIGNAL(activated(QModelIndex)), this,
SLOT(itemActivated(QModelIndex)));
setCentralWidget(treeView);
setWindowTitle(QObject::tr("Simple Tree Model"));
setUnifiedTitleAndToolBarOnMac(true);
}
示例15:
QAction *KeySequence::widget(QWidget *widget, const QList<QKeySequence> &shortcuts,
const QObject *receiver, const char *member)
{
QAction *act = KeySequence::action(widget, receiver, member);
act->setShortcuts(shortcuts);
return act;
}