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. Many data in single TableView cell
Qt 6.11 is out! See what's new in the release blog

Many data in single TableView cell

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 1.5k 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.
  • Y Offline
    Y Offline
    yako
    wrote on last edited by
    #1

    Hi.
    I want to make application to menage data in SQL data base, by using model/view architecture. Data should be viewed in TableView and there is my problem. I want to show many columns from database in the single cell. For instance: name, sex, age and edit this data by the delegate. It also should span cells with the same data.
    There is scheme:
    !http://i.imgur.com/bbAHwPH.png(Image)!

    Question: How to exactly do that? How to properly connect SQL model with QTableView?

    Thanks for you help!

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

      Hi and welcome to devnet,

      You should put a proxy model between the QTableView and the SQL model. The SQL model will contain the data from the database and your proxy will rearrange it for your view. You will also have to create a custom QStyledItemDelegate to show the data the way your want.

      The best is to have a look at the examples from the documentation, they show how to create custom views, models and delegates.

      Hope it helps

      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
      0
      • Y Offline
        Y Offline
        yako
        wrote on last edited by
        #3

        Thank you for answer.

        bq. You should put a proxy model ... rearrange it for your view

        I presumes it should be QAbstractProxyModel? Sadly, I can't find good example of using this class. Can you tell me little more about proxy models? How to exactly force putting many data items into single QStyledItemDelegate?
        Thanks.

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

          Have a look at the QSortFilterProxyModel it explains a bit the concepts.

          I'd rather group the data in the proxy model, the QStyleItemDelegate job is to present/edit the data not gather it like that.

          Depending on your original source, you could also use a QSqlQueryModel to fetch the data in a way that makes it easier for the view to show e.g. grouping the user information in the query

          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
          0

          • Login

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