本文整理汇总了C++中QTreeView::isVisible方法的典型用法代码示例。如果您正苦于以下问题:C++ QTreeView::isVisible方法的具体用法?C++ QTreeView::isVisible怎么用?C++ QTreeView::isVisible使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTreeView
的用法示例。
在下文中一共展示了QTreeView::isVisible方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testGlobalSearch
void TestGlobalSearch::testGlobalSearch()
{
QString filename(QFile::decodeName(FILES_DATA_DIR "/TestGlobalSearch.kexi"));
kDebug() << filename;
NewArgs args(m_argv);
args.vals[args.count - 1] = qstrdup(QFile::encodeName(filename).constData());
KexiAboutData aboutData;
aboutData.setProgramName(ki18n(metaObject()->className()));
int result = KexiMainWindow::create(args.count, args.vals, aboutData);
QVERIFY(kapp);
QCOMPARE(result, 0);
QLineEdit *lineEdit = kexiTester().widget<QLineEdit*>("globalSearch.lineEdit");
QVERIFY(lineEdit);
QTreeView *treeView = kexiTester().widget<QTreeView*>("globalSearch.treeView");
QVERIFY(treeView);
lineEdit->setFocus();
// enter "cars", expect 4 completion items
QTest::keyClicks(lineEdit, "cars");
QVERIFY(treeView->isVisible());
int globalSearchCompletionListRows = treeView->model()->rowCount();
QCOMPARE(globalSearchCompletionListRows, 4);
// add "x", expect no completion items and hidden list
QTest::keyClicks(lineEdit, "x");
QVERIFY(!treeView->isVisible());
globalSearchCompletionListRows = treeView->model()->rowCount();
QCOMPARE(globalSearchCompletionListRows, 0);
// Escape should clear
QTest::keyClick(lineEdit, Qt::Key_Escape, Qt::NoModifier, GUI_DELAY);
QVERIFY(lineEdit->text().isEmpty());
QTest::keyClicks(lineEdit, "cars");
QVERIFY(treeView->isVisible());
treeView->setFocus();
QTest::keyPress(treeView, Qt::Key_Down, Qt::NoModifier, GUI_DELAY);
QTest::keyPress(treeView, Qt::Key_Down, Qt::NoModifier, GUI_DELAY);
QTest::keyPress(treeView, Qt::Key_Down, Qt::NoModifier, GUI_DELAY);
// 3rd row should be "cars" form
QModelIndexList selectedIndices = treeView->selectionModel()->selectedRows();
QCOMPARE(selectedIndices.count(), 1);
QCOMPARE(treeView->model()->data(selectedIndices.first(), Qt::DisplayRole).toString(), QLatin1String("cars"));
// check if proper entry of Project Navigator is selected
QTest::keyPress(treeView, Qt::Key_Enter, Qt::NoModifier, GUI_DELAY);
KexiProjectNavigator *projectNavigator = kexiTester().widget<KexiProjectNavigator*>("KexiProjectNavigator");
QVERIFY(projectNavigator);
KexiPart::Item* selectedPartItem = projectNavigator->selectedPartItem();
QVERIFY(selectedPartItem);
QCOMPARE(selectedPartItem->name(), QLatin1String("cars"));
QCOMPARE(selectedPartItem->partClass(), QLatin1String("org.kexi-project.form"));
if (m_goToEventLoop) {
result = qApp->exec();
QCOMPARE(result, 0);
}
}