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


C++ QQuickView::errors方法代码示例

本文整理汇总了C++中QQuickView::errors方法的典型用法代码示例。如果您正苦于以下问题:C++ QQuickView::errors方法的具体用法?C++ QQuickView::errors怎么用?C++ QQuickView::errors使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QQuickView的用法示例。


在下文中一共展示了QQuickView::errors方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: errors

void tst_QQuickView::errors()
{
    QQuickView *view = new QQuickView;
    QVERIFY(view);
    QQmlTestMessageHandler messageHandler;
    view->setSource(testFileUrl("error1.qml"));
    QVERIFY(view->status() == QQuickView::Error);
    QVERIFY(view->errors().count() == 1);
    delete view;
}
开发者ID:ghjinlei,项目名称:qt5,代码行数:10,代码来源:tst_qquickview.cpp

示例2: errors

void tst_QQuickView::errors()
{
    {
        QQuickView view;
        QQmlTestMessageHandler messageHandler;
        view.setSource(testFileUrl("error1.qml"));
        QVERIFY(view.status() == QQuickView::Error);
        QVERIFY(view.errors().count() == 1);
    }
}
开发者ID:RobinWuDev,项目名称:Qt,代码行数:10,代码来源:tst_qquickview.cpp

示例3: main

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    QWidget widget;
    widget.setWindowTitle(QT_VERSION_STR);

    const QUrl source(QUrl::fromLocalFile(QLatin1String(SRCDIR) + QStringLiteral("/main.qml")));

    QHBoxLayout *hLayout = new QHBoxLayout(&widget);
    QGroupBox *groupBox = new QGroupBox("QuickWidget", &widget);
    QVBoxLayout *vLayout = new QVBoxLayout(groupBox);
    QQuickWidget *quickWidget = new QQuickWidget(groupBox);
    quickWidget->setMinimumSize(200, 200);
    vLayout->addWidget(quickWidget);
    quickWidget->setResizeMode(QQuickWidget::SizeRootObjectToView);
    quickWidget->setSource(source);
    if (quickWidget->status() == QQuickWidget::Error) {
        qWarning() << quickWidget->errors();
        return 1;
    }
    hLayout->addWidget(groupBox);

    groupBox = new QGroupBox("QQuickView/createWindowContainer", &widget);
    vLayout = new QVBoxLayout(groupBox);
    QQuickView *view = new QQuickView;
    view->setSource(source);
    if (view->status() == QQuickView::Error) {
        qWarning() << view->errors();
        return 1;
    }

    view->setResizeMode(QQuickView::SizeRootObjectToView);
    QWidget *container = QWidget::createWindowContainer(view, groupBox);
    container->setMinimumSize(200, 200);
    vLayout->addWidget(container);
    hLayout->addWidget(groupBox);

    const QRect availableGeometry = QApplication::desktop()->availableGeometry(&widget);
    widget.move(availableGeometry.center() - QPoint(widget.sizeHint().width() / 2, widget.sizeHint().height() / 2));

    widget.show();

    return app.exec();
}
开发者ID:2gis,项目名称:2gisqt5android,代码行数:45,代码来源:main.cpp

示例4: runExample

void QuickAndroidTests::runExample()
{

    QQuickView view;
//    QQmlApplicationEngine engine;
    view.setMinimumSize(QSize(480,640));
    view.setWidth(480);
    view.setHeight(640);
    view.setResizeMode(QQuickView::SizeRootObjectToView);

    view.engine()->addImportPath("qrc:///");
    view.setSource(QUrl("qrc:/main.qml"));
    view.show();

    wait(6000);

    QList<QQmlError> errors = view.errors();
    QVERIFY(errors.size() == 0);

}
开发者ID:vishnuQtdeveloper,项目名称:quickandroid,代码行数:20,代码来源:tst_quickandroidtests.cpp

示例5: addViewForScreen

    void GreeterApp::addViewForScreen(QScreen *screen) {
        // create view
        QQuickView *view = new QQuickView();
        view->setScreen(screen);
        view->setResizeMode(QQuickView::SizeRootObjectToView);
        //view->setGeometry(QRect(QPoint(0, 0), screen->geometry().size()));
        view->setGeometry(screen->geometry());
        m_views.append(view);

        // remove the view when the screen is removed, but we
        // need to be careful here since Qt will move the view to
        // another screen before this signal is emitted so we
        // pass a pointer to the view to our slot
        connect(this, &GreeterApp::screenRemoved, this, [view, this](QScreen *) {
            removeViewForScreen(view);
        });

        // always resize when the screen geometry changes
        connect(screen, &QScreen::geometryChanged, this, [view](const QRect &r) {
            view->setGeometry(r);
        });

        view->engine()->addImportPath(QStringLiteral(IMPORTS_INSTALL_DIR));

        // connect proxy signals
        connect(m_proxy, SIGNAL(loginSucceeded()), view, SLOT(close()));

        // we used to have only one window as big as the virtual desktop,
        // QML took care of creating an item for each screen by iterating on
        // the screen model. However we now have a better approach: we create
        // a view for each screen that compose the virtual desktop and thus
        // the QML code for each screen is responsible for drawing only its
        // screen. By doing so we actually make the screen model useless, but
        // we want to keep it for compatibility reasons, we do however create
        // one for each view and expose only the screen that the view belongs to
        // in order to avoid creating items with different sizes.
        ScreenModel *screenModel = new ScreenModel(screen, view);

        // set context properties
        view->rootContext()->setContextProperty(QStringLiteral("sessionModel"), m_sessionModel);
        view->rootContext()->setContextProperty(QStringLiteral("screenModel"), screenModel);
        view->rootContext()->setContextProperty(QStringLiteral("userModel"), m_userModel);
        view->rootContext()->setContextProperty(QStringLiteral("config"), *m_themeConfig);
        view->rootContext()->setContextProperty(QStringLiteral("sddm"), m_proxy);
        view->rootContext()->setContextProperty(QStringLiteral("keyboard"), m_keyboard);
        view->rootContext()->setContextProperty(QStringLiteral("primaryScreen"), QGuiApplication::primaryScreen() == screen);
        view->rootContext()->setContextProperty(QStringLiteral("__sddm_errors"), QString());

        // get theme main script
        QString mainScript = QStringLiteral("%1/%2").arg(m_themePath).arg(m_metadata->mainScript());
        QUrl mainScriptUrl;
        if (m_themePath.startsWith(QLatin1String("qrc:/")))
            mainScriptUrl = QUrl(mainScript);
        else
            mainScriptUrl = QUrl::fromLocalFile(mainScript);

        // load theme from resources when an error has occurred
        connect(view, &QQuickView::statusChanged, this, [view](QQuickView::Status status) {
            if (status != QQuickView::Error)
                return;

            QString errors;
            Q_FOREACH(const QQmlError &e, view->errors()) {
                qWarning() << e;
                errors += QLatin1String("\n") + e.toString();
            }

            qWarning() << "Fallback to embedded theme";
            view->rootContext()->setContextProperty(QStringLiteral("__sddm_errors"), errors);
            view->setSource(QUrl(QStringLiteral("qrc:/theme/Main.qml")));
        });
开发者ID:Adram,项目名称:sddm-1,代码行数:71,代码来源:GreeterApp.cpp


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