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. With QTableView, can I have the vertical header always be visible, even when the table is empty?
Qt 6.11 is out! See what's new in the release blog

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

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 3 Posters 3.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.
  • Guy GizmoG Offline
    Guy GizmoG Offline
    Guy Gizmo
    wrote on last edited by
    #1

    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?

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

      Hi,

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

      What is your use case ?

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

      Guy GizmoG 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

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

        What is your use case ?

        Guy GizmoG Offline
        Guy GizmoG Offline
        Guy Gizmo
        wrote on last edited by
        #3

        @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.

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

          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 ?

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

          Q 1 Reply Last reply
          0
          • SGaistS SGaist

            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 ?

            Q Offline
            Q Offline
            QtTester
            wrote on last edited by QtTester
            #5

            @SGaist
            When you search the table and there is no data match, the veritcal will be hidden , I also need to display it always.
            I already subclass from QSqlTableModel and implement headerData() for some feature, but how to make the vetical header always be visible?
            Thanks.

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

              Full range ?

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

              Q 1 Reply Last reply
              0
              • SGaistS SGaist

                Full range ?

                Q Offline
                Q Offline
                QtTester
                wrote on last edited by
                #7

                @SGaist
                did not get it what you mean.

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

                  You are asking for the header to be always visible, but does it need to show the whole range ?
                  By the way, could you provide a minimal compilable example so that it's possible to test/validate the behaviour ?

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

                  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