M
M
MrPanch2015-09-16 17:24:29
Qt
MrPanch, 2015-09-16 17:24:29

How to deal with XML parsing in Qt?

Hello!
There is a device for which the interface is written using Qt. There are no complete sources for editing, but there is a 1500-line xml config with a large number of drawings and the coordinates of these drawings that make up this very interface.
In order to make changes to the interface, you have to edit the coordinates manually, compile the cramfs image, upload it to the device, and only see how the changes look like on it.
I have not worked with Qt before, so I would like to know if there are ready-made solutions for parsing such xml and building an interface according to these coordinates in some tool. Googling did not give any results, so I have to assume that the parser will have to be written by myself, I will be glad if I'm wrong.
Tell me, in which direction is it worth digging? I will be grateful for any help. Thank you.
Code example:

<?xml version="1.0" encoding="utf-8"?>
<style>
  <Desktop>
    <bkg>
      <x>0</x><y>0</y>
      <w>800</w><h>480</h>
      <url>/project/res/style/main/bkg.jpg</url>
    </bkg>
    <talk>
      <x>23</x>
      <y>314</y>
      <normal>/project/res/style_rus/main/talk_up.png</normal>
      <press>/project/res/style_rus/main/talk_down.png</press>
    </talk>
    <monitor>
      <x>149</x>
      <y>314</y>
      <normal>/project/res/style_rus/main/monitor_up.png</normal>
      <press>/project/res/style_rus/main/monitor_down.png</press>
    </monitor>
    <media>
      <x>401</x>
      <y>314</y>
      <normal>/project/res/style_rus/main/media_up.png</normal>
      <press>/project/res/style_rus/main/media_down.png</press>
    </media>
    <setup>
      <x>653</x>
      <y>314</y>
      <normal>/project/res/style_rus/main/setup_up.png</normal>
      <press>/project/res/style_rus/main/setup_down.png</press>
    </setup>
    <logger>
      <x>275</x>
      <y>314</y>
      <normal>/project/res/style_rus/main/logger_up.png</normal>
      <press>/project/res/style_rus/main/logger_down.png</press>
    </logger>
    <alarmlogger>
      <x>528</x>
      <y>314</y>
      <normal>/project/res/style_rus/main/alarm_logger_up.png</normal>
      <press>/project/res/style_rus/main/alarm_logger_down.png</press>
    </alarmlogger>
  </Desktop>
</style>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaly Petrov, 2015-09-18
@MrPanch

I think there is what you need here: habrahabr.ru/sandbox/61031
In general, Qt now has two main classes for working with XML - QXmlStreamReader and QXmlStreamWriter.
On this page of the documentation, a description of working with them begins: doc.qt.io/qt-5/qtxml-index.html
And here are ready-made examples for working with XML: doc.qt.io/qt-5/examples-xml. html

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question