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. How to best model data for Model/View
Forum Updated to NodeBB v4.3 + New Features

How to best model data for Model/View

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 432 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.
  • V Offline
    V Offline
    valenrw
    wrote on last edited by
    #1

    Hi,

    First of all I'm sorry if this is not the correct place for this question.

    I'm working on various widgets(views) that work on data that is dependent on each other.

    For example; we have a list of people, and each person has a number of attributes and owns some files of different types.

    One widget is in charge of displaying all people, while another one works only with the files belonging to one specific person.

    How would you go about modeling the data?

    Option1: One model encompassing all data. Probably a Tree structured data with leaves of different types?. Delegates of each view take care of selecting which data is to be used.

    Option2: One model for the list of people (table), one model for the files of one person(tree/table), which must be updated when the person changes.

    Option3: ?

    Thanks a lot for your time.
    I'd appreciate any input

    Best, Valentin.

    JonBJ 1 Reply Last reply
    0
    • V valenrw

      Hi,

      First of all I'm sorry if this is not the correct place for this question.

      I'm working on various widgets(views) that work on data that is dependent on each other.

      For example; we have a list of people, and each person has a number of attributes and owns some files of different types.

      One widget is in charge of displaying all people, while another one works only with the files belonging to one specific person.

      How would you go about modeling the data?

      Option1: One model encompassing all data. Probably a Tree structured data with leaves of different types?. Delegates of each view take care of selecting which data is to be used.

      Option2: One model for the list of people (table), one model for the files of one person(tree/table), which must be updated when the person changes.

      Option3: ?

      Thanks a lot for your time.
      I'd appreciate any input

      Best, Valentin.

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @valenrw
      You want a simple correspondence for Qt's models and views. A model represents one table and should have one kind of data. Separate models, with separate views, for separate tables. You will want to go Option #2 rather than your Option 1.

      V 1 Reply Last reply
      2
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        Looks like structured data, did you consider putting them in a database such as SQLite ?

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

        V 1 Reply Last reply
        2
        • JonBJ JonB

          @valenrw
          You want a simple correspondence for Qt's models and views. A model represents one table and should have one kind of data. Separate models, with separate views, for separate tables. You will want to go Option #2 rather than your Option 1.

          V Offline
          V Offline
          valenrw
          wrote on last edited by
          #4

          @JonB Thanks for your response!

          1 Reply Last reply
          0
          • SGaistS SGaist

            Hi,

            Looks like structured data, did you consider putting them in a database such as SQLite ?

            V Offline
            V Offline
            valenrw
            wrote on last edited by
            #5

            @SGaist I had considered the option but thought I could keep avoiding implementing the database, which I've never done. Now it seems like implementing the models as QSqlTableModel and QSqlRelationalTableModel accessing the database is indeed the most sensible option in the long term. Thanks for your suggestion!

            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