It is possible to create QML components from files using Qt.createComponent(filename)
It is possible to create QML object from strings using Qt.createQmlObject(string)
It is possible to create QML components from code via Component {...}
But is it possible to create a QML component from a string? I mean without going thorugh the effort of saving it as a temp file just for the sake of using Qt.createComponent(filename)
?
EDIT: Just to clarify, I already have the components in this example form:
import QtQuick 2.0
Rectangle {
width: 100
height: 100
color: "red"
}
So I need to create a component from that string without instantiating it. I can't simply wrap the string in a "Component {" + string + "}"
because imports can not be declared inside a component. One solution would be to use complex parsing to insert the component just before the first element and after the imports, but it doesn't strike me as the most elegant solution to go about.