QtCompany предоставила ответ, которым я могу поделиться здесь.
Короче говоря, чтобы получить полную функциональность, ожидаемую от QML в плагине, который мне нужен для использования QQmlExtensionPlugin. Вот обновленные файлы для работы (Plugin.h и hello.qml)
hello.qml
import QtQuick 2.0
import org.example.PluginInterface 1.0
import "."
Rectangle {
id: page
width: 320; height: 240
color: "lightgray"
Text {
id: helloText
text: "Hello world!"
y: 30
anchors.horizontalCenter: page.horizontalCenter
font.pointSize: 24; font.bold: true
}
Rectangle {
id: innerPage
width: 300; height: 30
anchors.horizontalCenter: page.horizontalCenter
color: "blue"
Text {
id: nextOne
color: "white"
// text: "literal Text"
text: MySingleton.getTheText()
anchors.verticalCenter: innerPage.verticalCenter
anchors.horizontalCenter: innerPage.horizontalCenter
font.pointSize: 18; font.bold: false
}
}
OtherThing {
id: myOtherThing
x: 20; y: 150
}
}
Plugin.h
#ifndef PLUGIN_H
#define PLUGIN_H
#include <PluginIf.h>
#include <QQmlExtensionPlugin>
#include <QQmlEngine>
class Q_DECL_EXPORT Plugin : public QQmlExtensionPlugin, PluginInterface
{
Q_OBJECT
Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid)
Q_INTERFACES(PluginInterface)
public:
void init() override;
void registerTypes(const char *uri) override
{
qmlRegisterSingletonType(QUrl("qrc:/MySingleton.qml"), uri, 1, 0, "MySingleton");
}
};
#endif // PLUGIN_H