本文整理汇总了C++中QAbstractItemView::rootIndex方法的典型用法代码示例。如果您正苦于以下问题:C++ QAbstractItemView::rootIndex方法的具体用法?C++ QAbstractItemView::rootIndex怎么用?C++ QAbstractItemView::rootIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QAbstractItemView
的用法示例。
在下文中一共展示了QAbstractItemView::rootIndex方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: clicked
void tst_QColumnView::clicked()
{
ColumnView view;
QDirModel model;
view.setModel(&model);
view.resize(800,300);
view.show();
QModelIndex home = model.index(QDir::homePath());
QVERIFY(home.isValid());
view.setCurrentIndex(home);
QTest::qWait(ANIMATION_DELAY);
QModelIndex parent = home.parent();
QVERIFY(parent.isValid());
qRegisterMetaType<QModelIndex>("QModelIndex");
QSignalSpy clickedSpy(&view, SIGNAL(clicked(const QModelIndex &)));
QPoint localPoint = view.visualRect(home).center();
QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, localPoint);
QCOMPARE(clickedSpy.count(), 1);
qApp->processEvents();
if (sizeof(qreal) != sizeof(double)) {
QSKIP("Skipped due to rounding errors", SkipAll);
}
for (int i = 0; i < view.createdColumns.count(); ++i) {
QAbstractItemView *column = view.createdColumns.at(i);
if (column && column->selectionModel() && (column->rootIndex() == home))
QVERIFY(column->selectionModel()->selectedIndexes().isEmpty());
}
}
示例2: selectedColumns
void tst_QColumnView::selectedColumns()
{
ColumnView view;
QDirModel model;
view.setModel(&model);
view.resize(800,300);
view.show();
QModelIndex home = model.index(QDir::homePath());
view.setCurrentIndex(home);
QTest::qWait(ANIMATION_DELAY);
for (int i = 0; i < view.createdColumns.count(); ++i) {
QAbstractItemView *column = view.createdColumns.at(i);
if (!column)
continue;
if (!column->rootIndex().isValid() || column->rootIndex() == home)
continue;
QTRY_VERIFY(column->currentIndex().isValid());
}
}