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. Conception for a table with 1st row as a filter
Forum Updated to NodeBB v4.3 + New Features

Conception for a table with 1st row as a filter

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 3 Posters 1.2k 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.
  • C Offline
    C Offline
    Ch4rles
    wrote on last edited by
    #1

    Hi,
    I want to setup a table with a filter for each column. I want those filters (a regex string) to stay on the 1st row (or be direclty integrated in the header but I don't think that would be simplier).
    I have a working QAbstractTable and a QTableView. And I would like to set the filters in a QAbstractProxyModel. I've been experimenting with QSortFilterProxyModel by adding a row and shifting the row index from/to the model. But those classes are made to hide data from the model not add to it. So I'm having troubles with index management. I keep looking and I might ask a question about that later.
    But right now, I would like your thoughts on the conception/patterns. Is this the right way to do it ? Do you have other ideas ?
    Thanks,

    JonBJ 1 Reply Last reply
    0
    • C Offline
      C Offline
      Ch4rles
      wrote on last edited by
      #7

      Well here is what I came up with:
      https://github.com/Ch4rle5/columnFilteredTableExample

      1 Reply Last reply
      0
      • C Ch4rles

        Hi,
        I want to setup a table with a filter for each column. I want those filters (a regex string) to stay on the 1st row (or be direclty integrated in the header but I don't think that would be simplier).
        I have a working QAbstractTable and a QTableView. And I would like to set the filters in a QAbstractProxyModel. I've been experimenting with QSortFilterProxyModel by adding a row and shifting the row index from/to the model. But those classes are made to hide data from the model not add to it. So I'm having troubles with index management. I keep looking and I might ask a question about that later.
        But right now, I would like your thoughts on the conception/patterns. Is this the right way to do it ? Do you have other ideas ?
        Thanks,

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

        @Ch4rles said in Conception for a table with 1st row as a filter:

        I would like your thoughts on the conception/patterns

        Square peg, round hole? :) You'd be better doing it in the header. But admit I don't know how to, how much can you do with QHeaderView?

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

          Hi and welcome to devnet,

          Do you mean you want to filter each column independently ?

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

          C 1 Reply Last reply
          0
          • SGaistS SGaist

            Hi and welcome to devnet,

            Do you mean you want to filter each column independently ?

            C Offline
            C Offline
            Ch4rles
            wrote on last edited by
            #4

            @SGaist To be honest the principle is the same as the filters you can set in LIbreoffice or Excel. The main difference is that I want to use regex.
            So if any cell doesn't match to the filter of its column the whole row is hidden.

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

              You might want to use a technique similar to the one shown in the frozen column example.

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

              C 1 Reply Last reply
              0
              • SGaistS SGaist

                You might want to use a technique similar to the one shown in the frozen column example.

                C Offline
                C Offline
                Ch4rles
                wrote on last edited by
                #6

                @SGaist Thanks, that's a great tip! I didn't know this example, I'll definitely use it in the end.
                What about the idea of keeping the filters away from the model by using a proxy ? Do you think that's the right path ?

                1 Reply Last reply
                0
                • C Offline
                  C Offline
                  Ch4rles
                  wrote on last edited by
                  #7

                  Well here is what I came up with:
                  https://github.com/Ch4rle5/columnFilteredTableExample

                  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