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. Multiple column headers
Forum Updated to NodeBB v4.3 + New Features

Multiple column headers

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 3 Posters 692 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
    judethedude
    wrote on 7 Mar 2022, 19:34 last edited by
    #1

    Hi everyone,
    I'm trying to recreate this table in PyQt5 using both QDesigner and handcoding:
    a2d03d38-fb11-4319-8be0-d4ed9325d5e4-image.png

    Could anyone share any direction on how to get multiple columns into 'one'?
    Looking specifically at Created/Expiry date. Not sure how to recreate this, I'm using a Table View widget and pulling from my sqlite database/table.

    Kind regards,
    Jude

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 7 Mar 2022, 20:14 last edited by
      #2

      Hi,

      Possibly with QStyledItemDelegate or maybe a proxy model.

      Is it just to visualize the data or also edit it ?

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

      J 1 Reply Last reply 7 Mar 2022, 20:42
      1
      • S SGaist
        7 Mar 2022, 20:14

        Hi,

        Possibly with QStyledItemDelegate or maybe a proxy model.

        Is it just to visualize the data or also edit it ?

        J Offline
        J Offline
        judethedude
        wrote on 7 Mar 2022, 20:42 last edited by
        #3

        @SGaist thanks, I'll read up on that documentation, appreciate the response!

        The data is to be edited via line edits and buttons, sort of leads me to another question if you don't mind.

        I've been pulling from my model to populate my field edits like this:
        0d27a4cd-ebaf-479a-a312-f52886524cd8-image.png
        Which has been working fine, however not sure if I'm inserting to my model in the best way:
        0829987b-0005-44be-ad3b-83f315e3bbe8-image.png
        I noticed looking through the documentation of QSqlRecord, not sure if I should be building QSqlRecords and then inserting into the table?

        So I guess my question is, is there a better way to tie line edit's directly to a model field? As in, explicitly?

        Either way, I appreciate your response and I'll look through that documentation for sure.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 7 Mar 2022, 20:46 last edited by
          #4

          If you have a custom widget to edit your entries, then QDataWidgetMapper is your friend.

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

          J 1 Reply Last reply 7 Mar 2022, 20:56
          1
          • S SGaist
            7 Mar 2022, 20:46

            If you have a custom widget to edit your entries, then QDataWidgetMapper is your friend.

            J Offline
            J Offline
            judethedude
            wrote on 7 Mar 2022, 20:56 last edited by
            #5

            @SGaist that looks like exactly what I'm after, thanks again!

            1 Reply Last reply
            0
            • W Offline
              W Offline
              whut
              wrote on 8 Mar 2022, 03:24 last edited by
              #6

              The effect can be achieved by directly overwriting the widget on the header。More complex interactions can also be implemented。I refer to this page:

              https://www.qt.io/blog/2012/09/28/qt-support-weekly-27-widgets-on-a-header

              1 Reply Last reply
              2

              1/6

              7 Mar 2022, 19:34

              • Login

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