本文整理汇总了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;
}
示例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);
}
}
示例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();
}
示例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);
}
示例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")));
});