Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
[SOLVED] QQmlComponent: Component is not ready
Elegant last edited by
Okay, clearly this means the component is still loading but I don't understand how it not instant:
component->loadUrl(QUrl::fromLocalFile("Scripts/" + (QString)stageNode->GetTeam(turnIndex)->GetPet(i)->GetAura(j)->GetAuraId() + ".qml"));
object = component->create(objectContext);
//Call ApplyAuraStart; paramters are TeamNumber, PetNumber, AuraIndex and AuraDuration.
QMetaObject::invokeMethod(object, "applyAuraStart", Q_ARG(QVariant, turnIndex), Q_ARG(QVariant, i), Q_ARG(QVariant, j), Q_ARG(QVariant, stageNode->GetTeam(turnIndex)->GetPet(i)->GetAura(j)->GetDuration()));@
It's all done locally, in fact if I randomly create the QQmlContext, QQmlComponent, QObject in any class to open up a specific file, it works. Somehow when I started trying to open it in a for loop it fails. Calling invokeMethod seems to respond with the component not having loaded.
At this point, I do not have an alternative but to make this work, I just need to figure out how to wait until the component is ready.
Solution: Casting an int to a QString does NOT work QString::number(int) does.
AlterX last edited by
You have to use component's signal that notify to you when creation status has changed.