При каких условиях QQmlComponent :: create (QQmlContext *) завершается ошибкой, возвращая nullptr?В документации сказано только «Возвращает nullptr, если создание не удалось» без дополнительных подробностей.Мой бэкэнд-код C ++ пытается создать экземпляр MessageDialog из следующего qml:
import QtQuick 2.0
import QtQuick.Dialogs 1.1
MessageDialog {
id: messageDialog
title: "My message"
text: "Fill in this message from C++"
onAccepted: {
console.log("Knew you'd see it my way!")
// Hide the dialog
visible = false
}
Component.onCompleted: visible = true
}
А вот фрагмент моего внутреннего конструктора:
QQmlApplicationEngine engine;
// Note that component resource is local file URL,
// not network - no need to wait before calling create()?
QQmlComponent *component =
new QQmlComponent(&engine,
QStringLiteral("ui-components/MessageDialog.qml"));
// Following call returns nullptr
QObject *childItem = component->create();
Кто-нибудь знает почему?Спасибо!