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. Complex Data Model
Forum Updated to NodeBB v4.3 + New Features

Complex Data Model

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 3.0k 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.
  • J Offline
    J Offline
    jwomble
    wrote on last edited by
    #1

    Hello,
    I have an object named AVehicle that has two arrays - one of parts objects, and another of materials objects. I need to set up a QListView to display the parts, and a QTableView to display the materials. AVehicle is a subclass of QAbstractTableModel, and I have the ListView working. I don't know how to setup the delegate so that it will differentiate between the two Views.

    How should I handle this?

    Thanks!

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      I think that you are doing your work at the wrong level. Why is AVehicle a QAbstractTableModel? Wouldn't it make much more sense to let AVehicle have a QAbstractTableModel? That also makes it easy to make the distinction between the two lists/tables you need to feed your data to.

      You should see the item models are merely an interface to your data, but they should not be the data object. Take a look at "this more detailed explanation":http://developer.qt.nokia.com/doc/qt-4.7/model-view-programming.html#note-13 that I wrote down in the documentation.

      1 Reply Last reply
      0
      • J Offline
        J Offline
        jwomble
        wrote on last edited by
        #3

        That's where I was going wrong. Thanks!

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mmoll
          wrote on last edited by
          #4

          Hello and sorry for bringing up this old thread, but I felt it's better than starting a new one.

          On several occasions, I ran into problems very similar to jwombie's. I always wondered how to use QAIM correctly. (Side note: unfortunately, Qt's design isn't helpful here: there are Qt models that are adapters ( e.g. QSqlTableModel) and Qt models that are data stores (e.g. QStringListModel))

          I always tended to create adapter models that provide a view into my data, however that may be stored. But then I quickly ran into problems. I would not be able to tell what models to notify if the underlying data had changed. A google search suggested that I was doing it wrong and I should just use one big QAIM to avoid synchronization problems :-(

          So my question is: if a QAIM is best used as an adapter, is there any "recommended practice" how to synchronize models?
          I'm afraid of using a single, huge QAIM. Trying to squeeze all of my data into a hierarchical table would quickly become ugly (I tried. I gave up).

          Thanks
          Markus

          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