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. Which model to choose?
Forum Updated to NodeBB v4.3 + New Features

Which model to choose?

Scheduled Pinned Locked Moved General and Desktop
5 Posts 4 Posters 5.8k 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
    Jeroentjehome
    wrote on 12 Nov 2012, 09:44 last edited by
    #1

    Hi there,
    I've read through the model/view tutorial and want to implement this in my program to optimize the GUI time consumed. In a (QTableWidget) I display a Id, then a progressbar containing a RF receiving strength indication and in the third column a name can be given.
    What model should I chose? QStandardItemModel? A QAbstractItemModel?? I'm a bit lost in the model the use? What is the benefit or downside off either?
    Thx for any advise or link to where to read the stuff.
    Greetz

    Greetz, Jeroen

    1 Reply Last reply
    0
    • T Offline
      T Offline
      Tannin
      wrote on 12 Nov 2012, 10:13 last edited by
      #2

      QAbstractItemModel as the name suggests is an Interface, you can't use it directly, you'd have to derive from it and implement certain functions yourself (like QAbstractItemModel::data). QStandardItemModel is a generic implementation that you can use directly, with an interface similar to QTableWidget (you add and remove items and they get displayed).

      If this interface is good for your use case, QStandardItemModel will save you work. If you feel you'd have to take detours to get your data through the QStandardItemModel-interface (like converting data a lot) you're probably better off deriving from QAbstractItemModel.

      1 Reply Last reply
      0
      • S Offline
        S Offline
        Sam
        wrote on 12 Nov 2012, 10:58 last edited by
        #3

        Well its all based on your requirement, From the book "Advance Qt Programming":http://www.cuteqt.com/blog/wp-content/uploads/2009/06/Advanced_Qt_Programming.pdf in the first chapter of model/view table models it is given that :-

        bq. In addition to considering the two kinds of model, there are three types of model
        we can use. One type is any of the predefined models that Qt provides, for
        example, the QStringListModel, the QDirModel, and its successor the QFileSystem-
        Model—these can be used directly and require the least amount of work to use.

        bq. Another type is the QStandardItemModel; this is a generic model that can be used
        as a list, table, or tree model, and that provides an item-based API rather like
        the APIs offered by the convenience widgets (such as QTableWidget). Using a
        QStandardItemModel is ideal for those cases where we have data that fits neatly
        into the idiom of a list, table, or tree of items, and can be used as is or usually
        with very little adaptation.

        bq. And the last type is our own custom models derived
        from QAbstractItemModel (or from QAbstractListModel or QAbstractTable-
        Model). These are ideal when we want to achieve the best possible performance,
        or where our model doesn’t fit neatly into an item-based idiom.

        So pick one that you feel more handy/comfortable.

        1 Reply Last reply
        0
        • I Offline
          I Offline
          issam
          wrote on 12 Nov 2012, 12:16 last edited by
          #4

          Hi. I used in an application QAbstractItemModel. It caused me some problems specially when deleting and inserting rows and columns. So I switch to QStandardItemModel. It's more generic and I found it easiest. Well, you can download the application in my web-page under the source codes link : AHP method. The model implementation is in the file matrixmodel.h !

          I hope that it will help you :)

          http://www.iissam.com/

          1 Reply Last reply
          0
          • J Offline
            J Offline
            Jeroentjehome
            wrote on 12 Nov 2012, 14:24 last edited by
            #5

            Hi, Thx for the replies!
            Will try to implement the QStandardItemModel at first. It seems the most easy way to go.
            Thx again!

            Greetz, Jeroen

            1 Reply Last reply
            0

            3/5

            12 Nov 2012, 10:58

            • Login

            • Login or register to search.
            3 out of 5
            • First post
              3/5
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved