Calling a .QML file using XML

  • 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 :)

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

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

  • 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?

  • 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": in the Nokia website.

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

  • @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.

  • 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.

Log in to reply