How do I make the XML file path relative to the App Folder?
-
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.xmlI would like to do something like this:
source: file:///XML/myxmlfile.xmlI 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 10Thanks in advance for any assistance.
-
Hi,
This stack overflow thread shows multiple ways to achieve this.
-
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.