本文整理汇总了C++中QTableView::setHorizontalScrollMode方法的典型用法代码示例。如果您正苦于以下问题:C++ QTableView::setHorizontalScrollMode方法的具体用法?C++ QTableView::setHorizontalScrollMode怎么用?C++ QTableView::setHorizontalScrollMode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTableView
的用法示例。
在下文中一共展示了QTableView::setHorizontalScrollMode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: on_pbPosition_clicked
void SettingsDialog::on_pbPosition_clicked()
{
QScopedPointer< Gui::Dialog > dialog(new Gui::Dialog(Gui::Dialog::CenterOfScreen,this));
PositionModel *model = new PositionModel(dialog.data());
QTableView *view = new QTableView(dialog.data());
QItemSelectionModel *selectionModel = new QItemSelectionModel(model,dialog.data());
dialog->setWindowTitle(tr("Set position"));
QVBoxLayout *layout = new QVBoxLayout;
QDialogButtonBox *dialogButtons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel,
Qt::Horizontal,dialog.data());
connect(dialogButtons,SIGNAL(accepted()),dialog.data(),SLOT(accept()));
connect(dialogButtons,SIGNAL(rejected()),dialog.data(),SLOT(reject()));
view->setModel(model);
view->setItemDelegateForColumn(0,new PositionLabelDelegate);
view->setItemDelegateForColumn(1,new PositionDelegate(QApplication::palette()));
view->setSelectionBehavior(QAbstractItemView::SelectRows);
view->setSelectionMode(QAbstractItemView::SingleSelection);
view->setSelectionModel(selectionModel);
view->verticalHeader()->setVisible(false);
view->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
view->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
view->setEditTriggers(QAbstractItemView::NoEditTriggers);
layout->addWidget(view);
layout->addWidget(dialogButtons);
dialog->setLayout(layout);
dialog->resize(700,500);
connect(dialog.data(),SIGNAL(executed()),view,SLOT(resizeColumnsToContents()));
connect(dialog.data(),SIGNAL(executed()),view,SLOT(resizeRowsToContents()));
selectionModel->select(model->index(pbPosition->property("wallPosition").toInt(),0),
QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows);
view->scrollTo(model->index(pbPosition->property("wallPosition").toInt(),0));
if (dialog->exec() == QDialog::Accepted)
{
Wally::Application::Position p = static_cast<Wally::Application::Position> (selectionModel->currentIndex().row());
pbPosition->setProperty("wallPosition",static_cast<int> (p));
pbPosition->setText(positionToString(p).replace("&","&&"));
settingsModified();
}
}
示例2: QDialog
QmitkModulesDialog::QmitkModulesDialog(QWidget *parent, Qt::WindowFlags f) :
QDialog(parent, f)
{
this->setWindowTitle("MITK Modules");
QVBoxLayout* layout = new QVBoxLayout();
this->setLayout(layout);
QTableView* tableView = new QTableView(this);
QmitkModuleTableModel* tableModel = new QmitkModuleTableModel(tableView);
QSortFilterProxyModel* sortProxyModel = new QSortFilterProxyModel(tableView);
sortProxyModel->setSourceModel(tableModel);
sortProxyModel->setDynamicSortFilter(true);
tableView->setModel(sortProxyModel);
tableView->verticalHeader()->hide();
tableView->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
tableView->setSelectionBehavior(QAbstractItemView::SelectRows);
tableView->setSelectionMode(QAbstractItemView::ExtendedSelection);
tableView->setTextElideMode(Qt::ElideMiddle);
tableView->setSortingEnabled(true);
tableView->sortByColumn(0, Qt::AscendingOrder);
tableView->horizontalHeader()->setResizeMode(0, QHeaderView::ResizeToContents);
tableView->horizontalHeader()->setResizeMode(2, QHeaderView::ResizeToContents);
tableView->horizontalHeader()->setResizeMode(5, QHeaderView::ResizeToContents);
tableView->horizontalHeader()->setStretchLastSection(true);
tableView->horizontalHeader()->setCascadingSectionResizes(true);
layout->addWidget(tableView);
QDialogButtonBox* btnBox = new QDialogButtonBox(QDialogButtonBox::Close);
layout->addWidget(btnBox);
this->resize(800, 600);
connect(btnBox, SIGNAL(rejected()), this, SLOT(reject()));
}