本文整理汇总了C++中QTableView::mapToGlobal方法的典型用法代码示例。如果您正苦于以下问题:C++ QTableView::mapToGlobal方法的具体用法?C++ QTableView::mapToGlobal怎么用?C++ QTableView::mapToGlobal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTableView
的用法示例。
在下文中一共展示了QTableView::mapToGlobal方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QMainWindow
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);
//.........这里部分代码省略.........