本文整理汇总了C++中QWidgetAction::setShortcut方法的典型用法代码示例。如果您正苦于以下问题:C++ QWidgetAction::setShortcut方法的具体用法?C++ QWidgetAction::setShortcut怎么用?C++ QWidgetAction::setShortcut使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QWidgetAction
的用法示例。
在下文中一共展示了QWidgetAction::setShortcut方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setupActions
void ChannelView::setupActions() {
QSettings settings;
sortBy = static_cast<SortBy>(settings.value(sortByKey, SortByName).toInt());
QMenu *sortMenu = new QMenu(this);
QActionGroup *sortGroup = new QActionGroup(this);
QAction *sortByNameAction = new QAction(tr("Name"), this);
sortByNameAction->setActionGroup(sortGroup);
sortByNameAction->setCheckable(true);
if (sortBy == SortByName) sortByNameAction->setChecked(true);
connect(sortByNameAction, SIGNAL(triggered()), SLOT(setSortByName()));
sortMenu->addAction(sortByNameAction);
QAction *sortByUpdatedAction = new QAction(tr("Last Updated"), this);
sortByUpdatedAction->setActionGroup(sortGroup);
sortByUpdatedAction->setCheckable(true);
if (sortBy == SortByUpdated) sortByUpdatedAction->setChecked(true);
connect(sortByUpdatedAction, SIGNAL(triggered()), SLOT(setSortByUpdated()));
sortMenu->addAction(sortByUpdatedAction);
QAction *sortByAddedAction = new QAction(tr("Last Added"), this);
sortByAddedAction->setActionGroup(sortGroup);
sortByAddedAction->setCheckable(true);
if (sortBy == SortByAdded) sortByAddedAction->setChecked(true);
connect(sortByAddedAction, SIGNAL(triggered()), SLOT(setSortByAdded()));
sortMenu->addAction(sortByAddedAction);
QAction *sortByLastWatched = new QAction(tr("Last Watched"), this);
sortByLastWatched->setActionGroup(sortGroup);
sortByLastWatched->setCheckable(true);
if (sortBy == SortByLastWatched) sortByLastWatched->setChecked(true);
connect(sortByLastWatched, SIGNAL(triggered()), SLOT(setSortByLastWatched()));
sortMenu->addAction(sortByLastWatched);
QAction *sortByMostWatched = new QAction(tr("Most Watched"), this);
sortByMostWatched->setActionGroup(sortGroup);
sortByMostWatched->setCheckable(true);
if (sortBy == SortByMostWatched) sortByMostWatched->setChecked(true);
connect(sortByMostWatched, SIGNAL(triggered()), SLOT(setSortByMostWatched()));
sortMenu->addAction(sortByMostWatched);
QToolButton *sortButton = new QToolButton(this);
sortButton->setText(tr("Sort by"));
sortButton->setIcon(IconUtils::icon("sort"));
sortButton->setIconSize(QSize(16, 16));
sortButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
sortButton->setPopupMode(QToolButton::InstantPopup);
sortButton->setMenu(sortMenu);
QWidgetAction *widgetAction = new QWidgetAction(this);
widgetAction->setDefaultWidget(sortButton);
widgetAction->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_O));
statusActions << widgetAction;
markAsWatchedAction = new QAction(
IconUtils::icon("mark-watched"), tr("Mark all as watched"), this);
markAsWatchedAction->setEnabled(false);
markAsWatchedAction->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_W));
connect(markAsWatchedAction, SIGNAL(triggered()), SLOT(markAllAsWatched()));
statusActions << markAsWatchedAction;
showUpdated = settings.value(showUpdatedKey, false).toBool();
QAction *showUpdatedAction = new QAction(
IconUtils::icon("show-updated"), tr("Show Updated"), this);
showUpdatedAction->setCheckable(true);
showUpdatedAction->setChecked(showUpdated);
showUpdatedAction->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_U));
connect(showUpdatedAction, SIGNAL(toggled(bool)), SLOT(toggleShowUpdated(bool)));
statusActions << showUpdatedAction;
foreach (QAction *action, statusActions) {
window()->addAction(action);
IconUtils::setupAction(action);
}