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. Does QTableView call only on QAbstractTableModel's virtual functions when it needs to display data?
Forum Updated to NodeBB v4.3 + New Features

Does QTableView call only on QAbstractTableModel's virtual functions when it needs to display data?

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 790 Views 2 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.
  • D Offline
    D Offline
    DragonautX
    wrote on last edited by
    #1

    In "2.4 Setting up Headers for Columns and Rows" in the Qt5.7 Model View tutorial, the file "mymodel.cpp" has 4 virtual functions for the class MyModel: QAbstractTableModel : rowCount, columnCount, data, and headerData. I'm noticing that all these functions return data that is displayed by the QTableView view. Does that mean Qt views (like QTableView) communicate with Qt models by using virtual functions from the Qt models (like models of QAbstractItemModel and QAbstractTableModel)? I'm pretty sure that's how models and views work, I just want to make sure I'm getting it right.

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

      Hi,

      Not all methods are virtual. QAbstractItemModel provides the foundation to build your own custom models and you'll have to re-implement parts of the virtual methods in order to make it work the way you want it.

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

      1 Reply Last reply
      2
      • D Offline
        D Offline
        DragonautX
        wrote on last edited by
        #3

        That helps clear some confusion, thanks.

        1 Reply Last reply
        0
        • VRoninV Offline
          VRoninV Offline
          VRonin
          wrote on last edited by
          #4

          To clarify, that is an interface i.e. if you implement a View you should only rely on methods and signals defined in QAbstractItemModel so your view will work with all models implementing that interface correctly. QAbstractItemModel is the bridge between model and view (and delegate)

          "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
          ~Napoleon Bonaparte

          On a crusade to banish setIndexWidget() from the holy land of Qt

          1 Reply Last reply
          2

          • Login

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