Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Am I misunderstanding the docs, or is Qt.createQmlObject (almost) useless?
Forum Updated to NodeBB v4.3 + New Features

Am I misunderstanding the docs, or is Qt.createQmlObject (almost) useless?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
loading
1 Posts 1 Posters 577 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.
  • S Offline
    S Offline
    Stefan Monov76
    wrote on 30 Jan 2017, 20:07 last edited by
    #1

    From the Qt docs:

    Note that this function returns immediately, and therefore may not work if the qml string loads new components (that is, external QML files that have not yet been loaded). If this is the case, consider using Qt.createComponent() instead.

    But as far as I know, all QML files are "external", and any of them may have its load delayed arbitrarily long.

    E.g. if I do this:

    Qt.createQmlObject('\
        import QtQuick 2.0\n\
        Rectangle { }
        ',
        parentObject,
        "myRect");
    

    What happens if Rectangle has not been loaded by the time I execute this code? By this logic any code that uses Qt.createQmlObject with imports in the passed string is risky. So we should always use Qt.createComponent instead.

    I'm pretty sure I'm misunderstanding these docs, but I don't know what the right interpretation of them is.

    1 Reply Last reply
    0

    1/1

    30 Jan 2017, 20:07

    • Login

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