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. Calling a .QML file using XML
Qt 6.11 is out! See what's new in the release blog

Calling a .QML file using XML

Scheduled Pinned Locked Moved QML and Qt Quick
8 Posts 3 Posters 5.0k 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    Hello, I've been exploring a bit with XML and I'm wondering if it is possible to call a QML file using XML. Thank you :)

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

      What do you mean? An xml file is just a format for transferring or storing data? Could you elaborate please?

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

        I was asking if there is a way to call a qml function within an xml code. Thanks again :)

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

          XML is not code. It is not executed. However, it is perfectly reasonable to reference a QML file from within your XML file. Although I am not sure what your use case is.

          Could explain a little more background to what you are trying to do please? What is in your XML file? What is your project's goal?

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

            Ohh. My bad :).

            Well basically, my XML file only has text elements. I have a menu that has several buttons and each button leads to another page that is dependent on the things that I put on the XML file.

            I based my XML file off the "RestaurantApp":http://projects.developer.nokia.com/QMLRestaurantApp in the Nokia website.

            1 Reply Last reply
            0
            • D Offline
              D Offline
              DenisKormalev
              wrote on last edited by
              #6

              you can store js code in your xml file and execute it using eval() function in qml.

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

                @FlyingFish ah OK I see what you mean now. From memory that example uses the XML file to store content that should be displayed within QML. The content is "merged" into a list by means of the XMLListModel QML element used in conjunction with a ListView and a suitable delegate component.

                I've never tried to see if it is possible to embed snippets of QML inside a XMLListModel. Would be interesting to try it though.

                1 Reply Last reply
                0
                • D Offline
                  D Offline
                  DenisKormalev
                  wrote on last edited by
                  #8

                  ZapB, I've used js code in ListModel elements' properties. It works perfect using eval(). I don't think it will be not working with XMLListModel.

                  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