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. Preventing QSortFilterProxyModel from removing colums in QTableView
Qt 6.11 is out! See what's new in the release blog

Preventing QSortFilterProxyModel from removing colums in QTableView

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 1.1k 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
    jasig
    wrote on last edited by
    #1

    I have a custom QTableView which displays data using a custom QSortFilterProxyModel. In the custom proxy model I have reimplemented filterAcceptsColumn which returns true based on the selected columns in the source model of the proxy. What I'm noticing is that nothing is displayed in the table view when nothing is selected in the source model, however I want the table view to display empty cells in that case. I tried to see if there is a way to fix the row and column count in the QTableView, however this is not possible. Is there any way I can achieve what I want?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andreyc
      wrote on last edited by
      #2

      I guess you need to return the correct amount of "rowCount()":http://qt-project.org/doc/qt-5/qabstractitemmodel.html#rowCount and "columnCount()":http://qt-project.org/doc/qt-5/qabstractitemmodel.html#columnCount to display the empty cells.

      1 Reply Last reply
      0
      • J Offline
        J Offline
        jasig
        wrote on last edited by
        #3

        I made sure of that, however that doesn't solve the problem either.

        1 Reply Last reply
        0
        • J Offline
          J Offline
          jasig
          wrote on last edited by
          #4

          It seems like I didn't have the headers setup correctly and that's why the columns were being removed and added based on the return value of filterAcceptsColumn. Changing it to contain a horizontal and vertical header fixed the problem.

          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