With QTableView, can I have the vertical header always be visible, even when the table is empty?



  • I have a QTableView that displays both a horizontal and vertical header. When the table is empty (i.e. there are no rows), the horizontal header at the top is still visible, but the vertical header disappears. I'd like it if I could have it so that the vertical header is always visible. Is there any way to do that?


  • Lifetime Qt Champion

    Hi,

    The only way I currently see it is you have to make your model lie to the view.

    What is your use case ?



  • @SGaist It's not a use case so much as when the table view displays data after being empty, there's a noticeable but short fraction of a second where all of the cells are drawn but the vertical header isn't there, and then it redraws with the vertical header. The discontinuity is subtly jarring and I think it looks unprofessional, so I was wondering if I could just have the vertical header always be visible. It's more visually consistent too since the horizontal header is visible all of the time.

    If I can't do that, if it's possible to fix the discontinuity so that the vertical header draws at the same time as the cells, that would also be acceptable. And failing that, I can live with there being this visual discontinuity. I'd just prefer it wasn't there.


  • Lifetime Qt Champion

    Part of if might depend on how you are managing your data.

    Are you emptying the widget and replace the content of it or should it stay empty for a while ?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.