PDA

View Full Version : Create dynamic QML components from within C++?



mut
29th March 2016, 20:04
Hello

How to create a dynamic QML components from within C++?

I have tried this but it fails (below QObject pointer is Null):

QUrl t = QUrl(QStringLiteral("qrc:/path1/path11/path111/file.qml"));
QQmlComponent component(m_qmlEngine, t);
QObject *object = component.create(); // why object is NULL?

Is there another way to create a QML object from a .qml file?

Thanks

Mut

anda_skoa
29th March 2016, 22:32
Please tell me you did not just post the same question three times.

Cheers,
_

mut
29th March 2016, 23:00
Thanks for the reply. No at all, they have the same title.

anda_skoa
30th March 2016, 09:40
They all seem to be about loading a QML component from C++.

But lets for a moment assume that you are not spamming and want your account to be disabled, then the question is: have you checked the component's errors?

Cheers,
_