本文整理汇总了C++中TreeModel::thirdLevel方法的典型用法代码示例。如果您正苦于以下问题:C++ TreeModel::thirdLevel方法的具体用法?C++ TreeModel::thirdLevel怎么用?C++ TreeModel::thirdLevel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TreeModel
的用法示例。
在下文中一共展示了TreeModel::thirdLevel方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: moveGrip
void tst_QColumnView::moveGrip()
{
QFETCH(bool, reverse);
if (reverse)
qApp->setLayoutDirection(Qt::RightToLeft);
ColumnView view;
TreeModel model;
view.setModel(&model);
QModelIndex home = model.thirdLevel();
view.setCurrentIndex(home);
view.resize(640, 200);
view.show();
QTest::qWait(ANIMATION_DELAY);
int columnNum = view.createdColumns.count() - 2;
QVERIFY(columnNum >= 0);
QObjectList list = view.createdColumns[columnNum]->children();
QColumnViewGrip *grip = 0;
for (int i = 0; i < list.count(); ++i) {
if ((grip = qobject_cast<QColumnViewGrip *>(list[i]))) {
break;
}
}
if (!grip)
return;
QAbstractItemView *column = qobject_cast<QAbstractItemView *>(grip->parent());
int oldX = column->width();
QCOMPARE(view.columnWidths()[columnNum], oldX);
grip->moveGrip(10);
QCOMPARE(view.columnWidths()[columnNum], (oldX + (reverse ? -10 : 10)));
}
示例2: pullRug
void tst_QColumnView::pullRug()
{
QFETCH(bool, removeModel);
ColumnView view;
TreeModel model;
view.setModel(&model);
QModelIndex home = model.thirdLevel();
view.setCurrentIndex(home);
if (removeModel)
view.setModel(0);
else
view.setCurrentIndex(QModelIndex());
QTest::qWait(ANIMATION_DELAY);
// don't crash
}
示例3: scrollContentsBy
void tst_QColumnView::scrollContentsBy()
{
QFETCH(bool, reverse);
if (reverse)
qApp->setLayoutDirection(Qt::RightToLeft);
ColumnView view;
view.ScrollContentsBy(-1, -1);
view.ScrollContentsBy(0, 0);
TreeModel model;
view.setModel(&model);
view.ScrollContentsBy(0, 0);
QModelIndex home = model.thirdLevel();
view.setCurrentIndex(home);
QTest::qWait(ANIMATION_DELAY);
view.ScrollContentsBy(0, 0);
}
示例4: rootIndex
void tst_QColumnView::rootIndex()
{
ColumnView view;
// no model
view.setRootIndex(QModelIndex());
TreeModel model;
view.setModel(&model);
// A top level index
QModelIndex drive = model.firstLevel();
QVERIFY(view.visualRect(drive).isValid());
view.setRootIndex(QModelIndex());
QCOMPARE(view.HorizontalOffset(), 0);
QCOMPARE(view.rootIndex(), QModelIndex());
QVERIFY(view.visualRect(drive).isValid());
// A item under the rootIndex exists
QModelIndex home = model.thirdLevel();
QModelIndex homeFile = model.index(0, 0, home);
int i = 0;
while (i < model.rowCount(home) - 1 && !model.hasChildren(homeFile))
homeFile = model.index(++i, 0, home);
view.setRootIndex(home);
QCOMPARE(view.HorizontalOffset(), 0);
QCOMPARE(view.rootIndex(), home);
QVERIFY(!view.visualRect(drive).isValid());
QVERIFY(!view.visualRect(home).isValid());
if (homeFile.isValid())
QVERIFY(view.visualRect(homeFile).isValid());
// set root when there already is one and everything should still be ok
view.setRootIndex(home);
view.setCurrentIndex(homeFile);
view.scrollTo(model.index(0,0, homeFile));
QCOMPARE(view.HorizontalOffset(), 0);
QCOMPARE(view.rootIndex(), home);
QVERIFY(!view.visualRect(drive).isValid());
QVERIFY(!view.visualRect(home).isValid());
if (homeFile.isValid())
QVERIFY(view.visualRect(homeFile).isValid());
//
homeFile = model.thirdLevel();
home = homeFile.parent();
view.setRootIndex(home);
view.setCurrentIndex(homeFile);
view.show();
i = 0;
QModelIndex two = model.index(0, 0, homeFile);
while (i < model.rowCount(homeFile) - 1 && !model.hasChildren(two))
two = model.index(++i, 0, homeFile);
qApp->processEvents();
QTest::qWait(ANIMATION_DELAY);
view.setCurrentIndex(two);
view.scrollTo(two);
QTest::qWait(ANIMATION_DELAY);
qApp->processEvents();
QVERIFY(two.isValid());
QVERIFY(view.HorizontalOffset() != 0);
view.setRootIndex(homeFile);
QCOMPARE(view.HorizontalOffset(), 0);
}