Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. QTableView with QSqlQueryModel how to display values of two data fields into one cell
Forum Updated to NodeBB v4.3 + New Features

QTableView with QSqlQueryModel how to display values of two data fields into one cell

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
5 Posts 3 Posters 1.3k 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.
  • NatalieSN Offline
    NatalieSN Offline
    NatalieS
    wrote on last edited by
    #1

    Greeting,

    I have a requirement to display values from two data fields from sqlite table into table view where one cell of that table view would contain two values from two data fields from sqlite table. Is there a way to do it using QTableView and QSqlQueryModel or should I switch to something else? Any ideas would be greatly appreciated. Is it possible to create a custom widget and tight it to the model somehow?
    Below is the screenshot of my requirements.

    0_1510252705183_e2c8d1a5-448b-4ce1-80e6-3ea37aebad06-image.png
    Thank you very much for your help.
    Natalie

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

      Hi,

      Looks like a job for QStyledItemDelegate.

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

      JonBJ 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        Looks like a job for QStyledItemDelegate.

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

        @SGaist
        Will that address the requirement to combine two data fields into one cell of a QTableView though? IIRC it deals with 1 model field per 1 view column?

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

          Nothing forbids you to get more data from the model using the model index passed to the delegate.

          You can also use a proxy model that returns the data from two columns together.

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

          JonBJ 1 Reply Last reply
          1
          • SGaistS SGaist

            Nothing forbids you to get more data from the model using the model index passed to the delegate.

            You can also use a proxy model that returns the data from two columns together.

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

            @SGaist Thanks. Yet more to absorb...!

            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