本文整理汇总了C++中QTableView::setSizePolicy方法的典型用法代码示例。如果您正苦于以下问题:C++ QTableView::setSizePolicy方法的具体用法?C++ QTableView::setSizePolicy怎么用?C++ QTableView::setSizePolicy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTableView
的用法示例。
在下文中一共展示了QTableView::setSizePolicy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ctkExpandableWidgetTest1
//-----------------------------------------------------------------------------
int ctkExpandableWidgetTest1(int argc, char * argv [] )
{
QApplication::setStyle(new QPlastiqueStyle);
QApplication app(argc, argv);
QWidget topLevel;
QHBoxLayout* topLevelLayout = new QHBoxLayout;
topLevel.setLayout(topLevelLayout);
QWidget frame;
topLevelLayout->addWidget(&frame);
ctkExpandableWidget resizableFrame1(&frame);
QListView* listView = new QListView(&resizableFrame1);
listView->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred));
QVBoxLayout* resizableFrameLayout1 = new QVBoxLayout(&resizableFrame1);
resizableFrameLayout1->setContentsMargins(0,0,0,0);
resizableFrame1.setSizeGripMargins(QSize(2, 2));
resizableFrame1.setLayout(resizableFrameLayout1);
resizableFrameLayout1->addWidget(listView);
resizableFrame1.setOrientations(Qt::Horizontal | Qt::Vertical);
ctkExpandableWidget resizableFrame(&frame);
resizableFrame.setSizeGripInside(false);
QTreeView* treeView = new QTreeView(&resizableFrame);
treeView->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred));
QVBoxLayout* resizableFrameLayout = new QVBoxLayout(&resizableFrame);
resizableFrameLayout->setContentsMargins(0,0,0,0);
//resizableFrame.setSizeGripMargins(QSize(2, 2));
resizableFrame.setLayout(resizableFrameLayout);
resizableFrameLayout->addWidget(treeView);
resizableFrame.setOrientations(Qt::Horizontal);
QVBoxLayout *vbox = new QVBoxLayout;
vbox->setContentsMargins(0, 0, 0, 0);
vbox->addWidget(&resizableFrame1);
vbox->addWidget(&resizableFrame);
frame.setLayout(vbox);
ctkExpandableWidget resizableFrame0(&topLevel);
QTableView* tableView = new QTableView(&resizableFrame0);
tableView->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred));
QVBoxLayout* resizableFrameLayout0 = new QVBoxLayout(&resizableFrame0);
resizableFrameLayout0->setContentsMargins(0,0,0,0);
resizableFrame0.setSizeGripMargins(QSize(2, 2));
resizableFrame0.setLayout(resizableFrameLayout0);
resizableFrameLayout0->addWidget(tableView);
resizableFrame0.setOrientations(Qt::Vertical);
topLevelLayout->addWidget(&resizableFrame0);
topLevel.show();
if (argc < 2 || QString(argv[1]) != "-I" )
{
QTimer::singleShot(200, &app, SLOT(quit()));
}
return app.exec();
}
示例2: QMainWindow
//.........这里部分代码省略.........
// Hitting filter group
QActionGroup* hittingFilters = new QActionGroup(this);
hittingFilters->setExclusive(false);
// Filter helper
auto MakeHitterFilter = [=](QString text, QString toolTip, const auto& onFilterFn) -> QAction*
{
QAction* action = new QAction(this);
connect(action, &QAction::toggled, hitterSortFilterProxyModel, onFilterFn);
action->setText(text);
action->setToolTip(toolTip);
action->setCheckable(true);
action->toggle();
hittingFilters->addAction(action);
return action;
};
// Hitter filters
QAction* filterC = MakeHitterFilter("C", "Filter Catchers", &PlayerSortFilterProxyModel::OnFilterC);
QAction* filter1B = MakeHitterFilter("1B", "Filter 1B", &PlayerSortFilterProxyModel::OnFilter1B);
QAction* filter2B = MakeHitterFilter("2B", "Filter 2B", &PlayerSortFilterProxyModel::OnFilter2B);
QAction* filterSS = MakeHitterFilter("SS", "Filter SS", &PlayerSortFilterProxyModel::OnFilterSS);
QAction* filter3B = MakeHitterFilter("3B", "Filter 3B", &PlayerSortFilterProxyModel::OnFilter3B);
QAction* filterOF = MakeHitterFilter("OF", "Filter Outfielders", &PlayerSortFilterProxyModel::OnFilterOF);
QAction* filterCI = MakeHitterFilter("CI", "Filter Corner Infielders", &PlayerSortFilterProxyModel::OnFilterCI);
QAction* filterMI = MakeHitterFilter("MI", "Filter Middle Infielders", &PlayerSortFilterProxyModel::OnFilterMI);
QAction* filterDH = MakeHitterFilter("DH", "Filter Designated Hitters", &PlayerSortFilterProxyModel::OnFilterDH);
QAction* filterU = MakeHitterFilter("U", "Filter Utility", &PlayerSortFilterProxyModel::OnFilterU);
// Menu spacer
QWidget* spacer = new QWidget(this);
spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
// Completion Widget
QCompleter* completer = new QCompleter(this);
completer->setModel(playerTableModel);
completer->setCompletionColumn(PlayerTableModel::COLUMN_NAME);
completer->setFilterMode(Qt::MatchContains);
completer->setCaseSensitivity(Qt::CaseInsensitive);
// Select
auto HighlightPlayerInTable = [=](const QModelIndex& srcIdx)
{
// Lookup catergory
auto catergoryIdx = srcIdx.model()->index(srcIdx.row(), PlayerTableModel::COLUMN_CATERGORY);
auto catergory = srcIdx.model()->data(catergoryIdx).toUInt();
// Change to tab
hitterPitcherTabs->setCurrentIndex(CaterogyToTab(catergory));
// Select row
if (catergory == Player::Catergory::Hitter) {
auto proxyModel = dynamic_cast<QSortFilterProxyModel*>(hitterTableView->model());
auto proxyIdx = proxyModel->mapFromSource(srcIdx);
hitterTableView->selectRow(proxyIdx.row());
hitterTableView->setFocus();
} else if (catergory == Player::Catergory::Pitcher) {
auto proxyModel = dynamic_cast<QSortFilterProxyModel*>(pitcherTableView->model());
auto proxyIdx = proxyModel->mapFromSource(srcIdx);
pitcherTableView->selectRow(proxyIdx.row());
pitcherTableView->setFocus();
}
};