当前位置: 首页>>代码示例>>C++>>正文


C++ QTreeView::isVisible方法代码示例

本文整理汇总了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);
    }
}
开发者ID:crayonink,项目名称:calligra-2,代码行数:62,代码来源:TestGlobalSearch.cpp


注:本文中的QTreeView::isVisible方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。