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. Is it possible to use Qt.createComponent("Dialog.qml")
Qt 6.11 is out! See what's new in the release blog

Is it possible to use Qt.createComponent("Dialog.qml")

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
4 Posts 3 Posters 2.7k Views 2 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.
  • V Offline
    V Offline
    Volkeracho
    wrote on last edited by
    #1

    Im trying to implement a generic dialog system. Therefore I want to create different dialogs dynamically. But when I try to use

    Qt.createComponent("Dialog.qml")
    

    I get

    qml: Error creating new dialog, expected component status to be READY but it was not!
    qml: Component status is: 3
    qml: qrc:/Dialog.qml:-1 File not found
    

    And I realised that there is no Qml-File in the Qt-Install-Directory that represents a dialog. What I found was the plugin/module QtQuick/Dialogs and some DLL files. So my question is what name should I supply when using Qt.createDialog("<file_name.qml>") on native QML components like Dialog, Button or Label?

    1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      Hi @Volkeracho
      Not sure about the Dialog but for other components like Button or Label you can just add them in a separate file say for eg. MyButton.qml or MyLabel.qml and then use the URL's for these files depending upon where they are present i.e resource system or just local path.

      157

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by A Former User
        #3

        Or you can just use QML Component:

        Component {
            id: component
            Dialog { }
        }
        

        Creating an instance is a matter of calling Component::createObject():

        var dialog = component.createObject(parent);
        
        1 Reply Last reply
        2
        • V Offline
          V Offline
          Volkeracho
          wrote on last edited by
          #4

          Thanks a lot both of you, this will do nicely!

          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