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. After changing header height, how to fix problem in table rows

After changing header height, how to fix problem in table rows

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 2 Posters 631 Views
  • 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.
  • D Offline
    D Offline
    DzCode
    wrote on last edited by
    #1

    Hi all,

    I have a problem.

    There are 2 tableviews and they are splitted from each other with a splitter.

    One of the table's (table A) header has a header row with \n character. So that, its height is doubled. But in other table (table B) I have only single line header names.

    The thing I want to do is , I want to resize the header of table B according to the height of table A.

    However, when I use resize() method or even reimplementing painevent(), there will be a problem.

    Table B's height becomes like table A's size. However, the content of the tableview still positioned in the same place like before resizing table B's header height. It means that the first row of the tableview B is still in the same position, not repositioned according to new header height. How can I fix this?

    JonBJ 1 Reply Last reply
    1
    • D DzCode

      Hi all,

      I have a problem.

      There are 2 tableviews and they are splitted from each other with a splitter.

      One of the table's (table A) header has a header row with \n character. So that, its height is doubled. But in other table (table B) I have only single line header names.

      The thing I want to do is , I want to resize the header of table B according to the height of table A.

      However, when I use resize() method or even reimplementing painevent(), there will be a problem.

      Table B's height becomes like table A's size. However, the content of the tableview still positioned in the same place like before resizing table B's header height. It means that the first row of the tableview B is still in the same position, not repositioned according to new header height. How can I fix this?

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

      @DzCode said in After changing header height, how to fix problem in table rows:

      However, when I use resize() method or even reimplementing painevent(), there will be a problem.

      Since you say you are having a problem with this not working right, if you do not get any better, specific answers here for how to accomplish this would the best thing be to (try) making one of the header texts in table B have an extra \n at the end of it, so that way it will be working the same way as in table A?

      D 1 Reply Last reply
      0
      • JonBJ JonB

        @DzCode said in After changing header height, how to fix problem in table rows:

        However, when I use resize() method or even reimplementing painevent(), there will be a problem.

        Since you say you are having a problem with this not working right, if you do not get any better, specific answers here for how to accomplish this would the best thing be to (try) making one of the header texts in table B have an extra \n at the end of it, so that way it will be working the same way as in table A?

        D Offline
        D Offline
        DzCode
        wrote on last edited by DzCode
        #3

        @JonB

        no this is just a cheating.

        It is not a good idea to update all column headers in a big dataset. There are so many views using same models

        JonBJ 1 Reply Last reply
        0
        • D DzCode

          @JonB

          no this is just a cheating.

          It is not a good idea to update all column headers in a big dataset. There are so many views using same models

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

          @DzCode
          I don't think it's "cheating" :) And you will have to know somehow that the height of column A has changed in order to know you need to adjust column B.

          However, what about subclassing QHeaderView and override sizeHint() to return the desired height in B from the height in A? This is illustrated in the answer at https://stackoverflow.com/questions/11314566/how-to-set-height-of-horizontal-header-qheaderview .

          D 1 Reply Last reply
          0
          • JonBJ JonB

            @DzCode
            I don't think it's "cheating" :) And you will have to know somehow that the height of column A has changed in order to know you need to adjust column B.

            However, what about subclassing QHeaderView and override sizeHint() to return the desired height in B from the height in A? This is illustrated in the answer at https://stackoverflow.com/questions/11314566/how-to-set-height-of-horizontal-header-qheaderview .

            D Offline
            D Offline
            DzCode
            wrote on last edited by
            #5

            @JonB I dideverythig I can do.

            I reimplemented sizehint, paintevent or any other. All of them does not solve.

            Maybe you can understand the problem now. (Also, the sizes can change dynamically, so that it is not good to change sizehint event)

            2020-09-24 13_31_14-.png

            JonBJ 1 Reply Last reply
            0
            • D DzCode

              @JonB I dideverythig I can do.

              I reimplemented sizehint, paintevent or any other. All of them does not solve.

              Maybe you can understand the problem now. (Also, the sizes can change dynamically, so that it is not good to change sizehint event)

              2020-09-24 13_31_14-.png

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

              @DzCode
              I don't know. There is no "sizehint event". All I can say is from the link I showed you the question reads:

              I need adjust headers of two tables, standing near each other, because headers have different lines of text. It seems impossible.

              Which seems to be exactly what you are asking for. Posts elsewhere for the same question also say to do it the same way, by returning the desired value for MyCustomHeaderView::sizeHint().

              Best of luck.

              D 1 Reply Last reply
              0
              • JonBJ JonB

                @DzCode
                I don't know. There is no "sizehint event". All I can say is from the link I showed you the question reads:

                I need adjust headers of two tables, standing near each other, because headers have different lines of text. It seems impossible.

                Which seems to be exactly what you are asking for. Posts elsewhere for the same question also say to do it the same way, by returning the desired value for MyCustomHeaderView::sizeHint().

                Best of luck.

                D Offline
                D Offline
                DzCode
                wrote on last edited by
                #7

                @JonB yes I will ask on another platforms

                By the way, I should have use the same QHeaderView subclass for both of the table since I have implemented drag and drop between these tables via usign the header

                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