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?
QtWS25 Last Chance

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 572 Views
  • 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.
  • Stefan Monov76S Offline
    Stefan Monov76S Offline
    Stefan Monov76
    wrote on 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

    • Login

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