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. Table widget with different column widths per row?
Forum Updated to NodeBB v4.3 + New Features

Table widget with different column widths per row?

Scheduled Pinned Locked Moved Solved General and Desktop
9 Posts 2 Posters 845 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.
  • P Offline
    P Offline
    Publicnamer
    wrote on last edited by
    #1

    Is there any way to create a table widget in which each row can have differently sized columns?

    JonBJ 1 Reply Last reply
    0
    • P Publicnamer

      Is there any way to create a table widget in which each row can have differently sized columns?

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

      @Publicnamer
      No. It would not be a "table" then. (Example: how would you deal with table column headers?) You can "span" multiple columns in each row (if that does what you want), but that does not make the table's real columns have different widths per row.

      1 Reply Last reply
      1
      • P Offline
        P Offline
        Publicnamer
        wrote on last edited by
        #3

        I want to hide the column headers.
        Regarding spanning:
        So if I have 100 columns, each 15 pixels wide each, could I have some spans that are 30 pixels, others 90 pixels etc.?

        JonBJ 1 Reply Last reply
        0
        • P Publicnamer

          I want to hide the column headers.
          Regarding spanning:
          So if I have 100 columns, each 15 pixels wide each, could I have some spans that are 30 pixels, others 90 pixels etc.?

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

          @Publicnamer said in Table widget with different column widths per row?:

          I want to hide the column headers.

          Understood, but it does not affect that fact that table views will not allow a varying number of columns per row.

          So if I have 100 columns, each 15 pixels wide each, could I have some spans that are 30 pixels, others 90 pixels etc.?

          Yes, in principle. If you have a large number of narrow columns you can do quite a bit of spanning differently per row to achieve rows which look like they have varying column widths.

          However, be aware this is not totally flexible. I can see two "gotchas":

          • You will end up with your data "dotted around" the columns. One row might have data in just columns 0, 33 & 67, another might have data in 20, 40, 50 & 99. Not forbidden, but could be a management issue.

          • You must still think in terms of the actual columns are in. If one row has data in column 10 spanning 20 columns, and another has data in column 15 spanning 10 columns, these are not totally independent of each other. Here, for example they "share" columns 15 to 20, with implications you can imagine for layout.

          P 1 Reply Last reply
          0
          • JonBJ JonB

            @Publicnamer said in Table widget with different column widths per row?:

            I want to hide the column headers.

            Understood, but it does not affect that fact that table views will not allow a varying number of columns per row.

            So if I have 100 columns, each 15 pixels wide each, could I have some spans that are 30 pixels, others 90 pixels etc.?

            Yes, in principle. If you have a large number of narrow columns you can do quite a bit of spanning differently per row to achieve rows which look like they have varying column widths.

            However, be aware this is not totally flexible. I can see two "gotchas":

            • You will end up with your data "dotted around" the columns. One row might have data in just columns 0, 33 & 67, another might have data in 20, 40, 50 & 99. Not forbidden, but could be a management issue.

            • You must still think in terms of the actual columns are in. If one row has data in column 10 spanning 20 columns, and another has data in column 15 spanning 10 columns, these are not totally independent of each other. Here, for example they "share" columns 15 to 20, with implications you can imagine for layout.

            P Offline
            P Offline
            Publicnamer
            wrote on last edited by Publicnamer
            #5

            @JonB My goal here is to basically divide the row into 2 areas each of varying size. The left area will have n columns, the right area will have m columns. To allow for fine-grained control of column sizes, I'll probably have to have n+m=100 columns and each column will be a fixed size e.g. 15 pixels.

            JonBJ 1 Reply Last reply
            0
            • P Publicnamer

              @JonB My goal here is to basically divide the row into 2 areas each of varying size. The left area will have n columns, the right area will have m columns. To allow for fine-grained control of column sizes, I'll probably have to have n+m=100 columns and each column will be a fixed size e.g. 15 pixels.

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

              @Publicnamer
              I have replied as clearly as I can. Why don't you try the result with, say, 10 columns and have a play to see how the spanning and widths work out for you, before proceeding to full implementation?

              P 1 Reply Last reply
              0
              • JonBJ JonB

                @Publicnamer
                I have replied as clearly as I can. Why don't you try the result with, say, 10 columns and have a play to see how the spanning and widths work out for you, before proceeding to full implementation?

                P Offline
                P Offline
                Publicnamer
                wrote on last edited by
                #7

                @JonB Just curious, where is the API for this span concept that you're talking about?

                JonBJ 1 Reply Last reply
                0
                • P Publicnamer

                  @JonB Just curious, where is the API for this span concept that you're talking about?

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

                  @Publicnamer
                  https://doc.qt.io/qt-5.15/qtableview.html#setSpan

                  P 1 Reply Last reply
                  0
                  • JonBJ JonB

                    @Publicnamer
                    https://doc.qt.io/qt-5.15/qtableview.html#setSpan

                    P Offline
                    P Offline
                    Publicnamer
                    wrote on last edited by
                    #9

                    @JonB OK, I've found that it works thanks.

                    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