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