Important: Please read the Qt Code of Conduct -

[Solved] Best method to Display Data from XML: TableView or ListView or...

  • Hello Forum.

    My little Project will contain some kind of Contact Database which includes different Data (Addresses, eMail Data, Type of Contact, Links etc.). These Type of Data should be categorized in the following way (as it currently stands):

    • Federal State
    • Region
    • City
    • Postal Area Code
    • Name of Contact
    • Type of Contact [multiple Values possible]
    • Addresses
    • eMail [Clicking the eMail Address should be open with mailto:]
    • Weblink [Clicking the Weblink should be opened directly in a already semi-implemented WebView]

    The Data should be:

    • Searchable by the User while selecting one or more specific Categories or simply search for everything

    As I am not familiar with JSON (and I am not sure If JSON can used in the Way I want it], I think I will store those Data either

    • In one Single XML File
    • Or in 1 XML File per Federal State (which will be 16 here in that case)

    It is possible, that more Countrys will be added at a later point.

    I currently play with a QTableView and I think it is very good customizable(?!) for my plans.

    Any Beginner Tips how to approach it and what View I should use in that case, are greatly welcome :)


  • My approach would be a custom widget to display the information from a particular data index and not try to use QTableView for this purpose. You have very specific fields to display. If there are changes to the data you simply need to update your custom widget. If the fields were unknown or random using a QTableView or QTableWidget makes more sense.

    For all the records a QListView or QListWidget (depends on how much data you anticipate on having). If using a QListWidget you can create a custom QListWidgetItem that would display information from its associated record in some way that is easy to visually scan. When an item in the list is selected the contents populate your custom widget for viewing (or editing).

    For the data, if using XML or JSON, (note: SQL database might be the best option in this case) I think it is more important to design your format carefully and consider future additions. There may be advantages of one or the other but I don't think this is as important as how you use make use of any of these options.

  • @Rondog Sorry I simply forgot to answer. Just wanted to say Thanks for your Feedback.

    I decided to use a QTableView. I read the Data from the different XML Files into different QTableViews. The Database Files are read after manually selection. So for now, no Speed Problems. I hope it stays that way, when all Data are edited in.

    Thanks :)

Log in to reply