Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] QQmlComponent: Component is not ready
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] QQmlComponent: Component is not ready

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 6.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    Elegant
    wrote on 11 Nov 2013, 06:51 last edited by
    #1

    Okay, clearly this means the component is still loading but I don't understand how it not instant:
    @objectContext->setContextProperty("petStage", stageNode);
    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.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      AlterX
      wrote on 23 Nov 2013, 14:44 last edited by
      #2

      You have to use component's signal that notify to you when creation status has changed.

      Qt Ambassador
      Real-time cooperative teams: http://www.softairrealfight.net
      Free Real-time network platform sdk: https://github.com/AlterX76/Solomon

      https://codereview.qt-project.org/...

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved