Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [solved] XML model?
Forum Updated to NodeBB v4.3 + New Features

[solved] XML model?

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 4.3k 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.
  • T Offline
    T Offline
    ThaRez
    wrote on last edited by
    #1

    Hello
    I'd would like to create a server that provides data as XML and a client that shows this in a QTableView. The data is logged from a system, so it changes regularly.

    My question is:
    Can I somehow create model approach similar to an QSqlModel, so that I easily could display the data and keep it synced over a TCP connection? Thanks!

    Richard

    1 Reply Last reply
    0
    • G Offline
      G Offline
      gmaro
      wrote on last edited by
      #2

      Hi,

      I don't think there is a direct approach, the reason is since sql tables are well suited to display in table format "as is" and xml is rather suitable to display as a structured tree. Simple question is how to display "properly" the structure of items that have other child items and those items have also child items? Many ways to do that, but tree is more suitable.

      It may be cofortable for you to use the QDomDocument or QXmlStreamReader.
      Please look also ath the "Simple DOM Model Example":http://qt-project.org/doc/qt-4.8/itemviews-simpledommodel.html maybe you can use similar approach but change only the way of viewing the data.

      1 Reply Last reply
      0
      • T Offline
        T Offline
        ThaRez
        wrote on last edited by
        #3

        Thank you! I do see your point, but what about creating a custom data model based on the XML format? Could this be done is such way, and if so, how hard is it?
        Richard

        1 Reply Last reply
        0
        • G Offline
          G Offline
          gmaro
          wrote on last edited by
          #4

          That depends what do you need to do with it.
          If you want to create some new model based on the QAbstractItemModel class, you need to prepare for quite a lot of work i think.
          Personally I don't think you need to do that.

          If your xml is suitable to display in a table. Just use the QTableView and QStandardItemModel which is simple and ready to use.

          I think some simple less-work approach will be just to:
          set QStandardItemModel to QTableView,
          when new xml comes in, parse it (using QDomDocument, QXmlStreamReader or even QXmlSimpleReader), and fill/replace the QStandardItemModel data. The data in the view will be automatically refreshed.

          If you still want to subclass the QAbstractItemModel, i thinkt the Simple DOM Model Example shows this really good, and as you see, you'll have a lot of coding in that case.

          1 Reply Last reply
          0
          • T Offline
            T Offline
            ThaRez
            wrote on last edited by
            #5

            Ok, Thank you, that's what I wanted to know.
            Best regards
            Richard

            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