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. How to create this object dynamically?

How to create this object dynamically?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 2 Posters 195 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.
  • Q Offline
    Q Offline
    qwe3
    wrote on 6 Jun 2021, 17:16 last edited by
    #1

    Hi. I would like to dynamically create MapQuickItem, but I can't. My code:

    anotherItem = Qt.createQmlObject('import QtLocation 5.15; MapQuickItem {sourceItem: Image { id: xyz; source: "qrc:/abc.png"}}', map)
    

    I get error:

    Image is not a type
    
    J 1 Reply Last reply 7 Jun 2021, 05:23
    0
    • Q qwe3
      6 Jun 2021, 17:16

      Hi. I would like to dynamically create MapQuickItem, but I can't. My code:

      anotherItem = Qt.createQmlObject('import QtLocation 5.15; MapQuickItem {sourceItem: Image { id: xyz; source: "qrc:/abc.png"}}', map)
      

      I get error:

      Image is not a type
      
      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 7 Jun 2021, 05:23 last edited by
      #2

      @qwe3 Isn't "import QtQuick 2.0" missing in your QML string?
      https://doc.qt.io/qt-5/qml-qtquick-image.html

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      3

      1/2

      6 Jun 2021, 17:16

      • Login

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