本文整理汇总了C++中QAction::toggle方法的典型用法代码示例。如果您正苦于以下问题:C++ QAction::toggle方法的具体用法?C++ QAction::toggle怎么用?C++ QAction::toggle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QAction
的用法示例。
在下文中一共展示了QAction::toggle方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: eventFilter
bool InputWidget::eventFilter(QObject *watched, QEvent *event)
{
if (event->type() != QEvent::KeyPress)
return false;
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
// keys from BufferView should be sent to (and focus) the input line
BufferView *view = qobject_cast<BufferView *>(watched);
if (view) {
if (keyEvent->text().length() == 1 && !(keyEvent->modifiers() & (Qt::ControlModifier ^ Qt::AltModifier))) { // normal key press
QChar c = keyEvent->text().at(0);
if (c.isLetterOrNumber() || c.isSpace() || c.isPunct() || c.isSymbol()) {
setFocus();
QCoreApplication::sendEvent(inputLine(), keyEvent);
return true;
}
}
return false;
}
else if (watched == ui.inputEdit) {
if (keyEvent->matches(QKeySequence::Find)) {
QAction *act = GraphicalUi::actionCollection()->action("ToggleSearchBar");
if (act) {
act->toggle();
return true;
}
}
return false;
}
return false;
}
示例2: keyPressEvent
void SearchBox::keyPressEvent(QKeyEvent *event)
{
#if 0
QString ksq = KeyEventToSequence(event);
if (ksq == "/") {
QAction *action = getMainWnd()->findChild<QAction*>("action_Search");
action->toggle();
event->accept();
return;
}
QString textBefore = text();
QLineEdit::keyPressEvent(event);
if (ksq == "Shift+Return"){
qDebug() << ksq;
emit getMainWnd()->findChild<QAction*>("action_SearchPrev")->triggered();
}
else if (ksq.indexOf("Return") != -1) {
qDebug() << ksq;
emit getMainWnd()->findChild<QAction*>("action_SearchNext")->triggered();
}
else if (textBefore != text()) {
emit searchItem(text());
}
else {
qDebug() << ksq;
}
#endif
QLineEdit::keyPressEvent(event);
}
示例3: OLD_MAIN
OLD_MAIN(QWidget* pParent = nullptr)
: QMainWindow(pParent)
{
Q_INIT_RESOURCE(Resources);
// Settings persistence
ReadSettings();
// Appearance LUT
PlayerApperances appearances;
// Build player table model from file
PlayerTableModel* playerTableModel = new PlayerTableModel(this);
playerTableModel->LoadHittingProjections(appearances);
playerTableModel->LoadPitchingProjections(appearances);
playerTableModel->CalculateHittingScores();
playerTableModel->CalculatePitchingScores();
playerTableModel->InitializeTargetValues();
// Draft delegate
DraftDelegate* draftDelegate = new DraftDelegate(playerTableModel);
LinkDelegate* linkDelegate = new LinkDelegate(this);
TagDelegate* tagDelegate = new TagDelegate(this);
// Hitter sort-model
PlayerSortFilterProxyModel* hitterSortFilterProxyModel = new PlayerSortFilterProxyModel(Player::Hitter);
hitterSortFilterProxyModel->setSourceModel(playerTableModel);
hitterSortFilterProxyModel->setSortRole(PlayerTableModel::RawDataRole);
// Hitter table view
QTableView* hitterTableView = MakeTableView(hitterSortFilterProxyModel, true, PlayerTableModel::COLUMN_Z);
hitterTableView->setItemDelegateForColumn(FindColumn(hitterSortFilterProxyModel, PlayerTableModel::COLUMN_DRAFT_BUTTON), draftDelegate);
hitterTableView->setItemDelegateForColumn(FindColumn(hitterSortFilterProxyModel, PlayerTableModel::COLUMN_ID_LINK), linkDelegate);
hitterTableView->setItemDelegateForColumn(FindColumn(hitterSortFilterProxyModel, PlayerTableModel::COLUMN_FLAG), tagDelegate);
hitterTableView->setEditTriggers(QAbstractItemView::DoubleClicked | QAbstractItemView::SelectedClicked);
// Context menu
QMenu* contextMenu = new QMenu();
contextMenu->addAction("&Remove Player");
// Apply to hitter table view
hitterTableView->setContextMenuPolicy(Qt::CustomContextMenu);
connect(hitterTableView, &QWidget::customContextMenuRequested, [=](const QPoint& pos) {
QPoint globalPos = hitterTableView->mapToGlobal(pos);
QAction* selectedItem = contextMenu->exec(globalPos);
if (selectedItem) {
auto proxyIndex = hitterTableView->indexAt(pos);
auto srcIndex = hitterSortFilterProxyModel->mapToSource(proxyIndex);
playerTableModel->RemovePlayer(srcIndex.row());
}
});
// Pitcher sort-model
PlayerSortFilterProxyModel* pitcherSortFilterProxyModel = new PlayerSortFilterProxyModel(Player::Pitcher);
pitcherSortFilterProxyModel->setSourceModel(playerTableModel);
pitcherSortFilterProxyModel->setSortRole(PlayerTableModel::RawDataRole);
// Pitcher table view
QTableView* pitcherTableView = MakeTableView(pitcherSortFilterProxyModel, true, PlayerTableModel::COLUMN_Z);
pitcherTableView->setItemDelegateForColumn(FindColumn(pitcherSortFilterProxyModel, PlayerTableModel::COLUMN_DRAFT_BUTTON), draftDelegate);
pitcherTableView->setItemDelegateForColumn(FindColumn(pitcherSortFilterProxyModel, PlayerTableModel::COLUMN_ID_LINK), linkDelegate);
pitcherTableView->setItemDelegateForColumn(FindColumn(pitcherSortFilterProxyModel, PlayerTableModel::COLUMN_FLAG), tagDelegate);
pitcherTableView->setEditTriggers(QAbstractItemView::DoubleClicked | QAbstractItemView::SelectedClicked);
// Top/Bottom splitter
QSplitter* topBottomSplitter = new QSplitter(Qt::Vertical);
topBottomSplitter->setContentsMargins(5, 5, 5, 5);
// Hitter/Pitcher tab View
enum PlayerTableTabs { Hitters, Pitchers, Unknown };
QTabWidget* hitterPitcherTabs = new QTabWidget(this);
hitterPitcherTabs->insertTab(PlayerTableTabs::Hitters, hitterTableView, "Hitters");
hitterPitcherTabs->insertTab(PlayerTableTabs::Pitchers, pitcherTableView, "Pitchers");
topBottomSplitter->addWidget(hitterPitcherTabs);
// Tab lookup helper
auto CaterogyToTab = [](uint32_t catergory)
{
switch (catergory)
{
case Player::Hitter:
return PlayerTableTabs::Hitters;
case Player::Pitcher:
return PlayerTableTabs::Pitchers;
default:
return PlayerTableTabs::Unknown;
}
};
// Drafted filter action
QAction* filterDrafted = new QAction(this);
connect(filterDrafted, &QAction::toggled, hitterSortFilterProxyModel, &PlayerSortFilterProxyModel::OnFilterDrafted);
connect(filterDrafted, &QAction::toggled, pitcherSortFilterProxyModel, &PlayerSortFilterProxyModel::OnFilterDrafted);
filterDrafted->setText(tr("Drafted"));
filterDrafted->setToolTip("Toggle Drafted Players");
filterDrafted->setCheckable(true);
filterDrafted->toggle();
QAction* filterReplacement = new QAction(this);
connect(filterReplacement, &QAction::toggled, hitterSortFilterProxyModel, &PlayerSortFilterProxyModel::OnFilterReplacement);
//.........这里部分代码省略.........