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. [SOLVED]Qt.createQmlComponent and qrc

[SOLVED]Qt.createQmlComponent and qrc

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 2.3k 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.
  • I Offline
    I Offline
    ixSci
    wrote on last edited by
    #1

    Hi all!

    I use QML in C++ resources and have stumbled on some weird behaviour. When I use Qt.createQmlComponent("import QtQuick 1.0; MyType{}) in my QML file and run it under QMLViewer it goes ok. But when I run it from my application it tells me "Error: Qt.createQmlComponent failed to create object: MyType is not a type". QML file MyType is in the resources and actively used by other components without any problems. Is it a bug or I missed something?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      aalpert
      wrote on last edited by
      #2

      You're missing the correct import statement. When the qmlviewer runs it, it probably gets picked up with the implicit import "." but this doesn't seem to happen when run from the application in a script.

      You can file a bug anyways, because the behavior seems inconsistent and that alone is a bug. But you should be able to get it working if you explicitly import MyType instead of hoping the implicit imports pick it up. If the correct import statement still doesn't work, then it's definitely a bug.

      1 Reply Last reply
      0
      • I Offline
        I Offline
        ixSci
        wrote on last edited by
        #3

        aalpert, thank you for the clarification.

        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