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 do I make the XML file path relative to the App Folder?
Forum Updated to NodeBB v4.3 + New Features

How do I make the XML file path relative to the App Folder?

Scheduled Pinned Locked Moved Solved QML and Qt Quick
qt6qmlxmllistmodelfilepath
3 Posts 2 Posters 1.9k 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.
  • I Offline
    I Offline
    ijststd
    wrote on 6 Dec 2022, 20:50 last edited by
    #1

    I am new to Qt & QML. I am working on an app that will connect to and interface with different embedded systems via a virtual serial port. Each embedded system is different and I am using XML files to describe the differences. The XML files CANNOT be included in a resource and MUST be in separate files in a folder on the drive. I would like to have all XML files in an XML sub folder of the Qt application.
    The XML files are used as the “source” property of XmlListModel. The Qt help for the source property simply says “The location of the XML data source.”

    The only way I have been able to get this to work is be providing the complete path to the XML file. This is not very portable.

    Complete path - works.
    source: file:///D:/Projects/Project Name/App Folder/XML/myxmlfile.xml

    I would like to do something like this:
    source: file:///XML/myxmlfile.xml

    I have tried every syntax suggestion I could find. They all result in the following message:
    “The system cannot find the path specified.”
    Which in no way helps me to figure out where it actually looked.

    So, my question is:
    How do I make the XML file path relative to the Qt App Folder?

    Additional Info:
    Qt 6.4.1 on Windows 10

    Thanks in advance for any assistance.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 6 Dec 2022, 21:23 last edited by
      #2

      Hi,

      This stack overflow thread shows multiple ways to achieve this.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • I Offline
        I Offline
        ijststd
        wrote on 6 Dec 2022, 22:22 last edited by
        #3

        Thank You. That looks like it might be what I need. If not, it may help get me there.

        I will test it as soon as I can. I am having problems with Qt Creator. I just updated to 9.0.0 and now Qt Creator crashes/closes as soon as I try to go to the designer.

        I just posted this issue.

        1 Reply Last reply
        0

        3/3

        6 Dec 2022, 22:22

        • Login

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