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. How do I iterate across the columns of a QTableView so I can find the total width of the table?

How do I iterate across the columns of a QTableView so I can find the total width of the table?

Scheduled Pinned Locked Moved Solved General and Desktop
qtableview c++dialog
6 Posts 3 Posters 638 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.
  • J Offline
    J Offline
    jdent
    wrote on 22 Mar 2024, 22:57 last edited by jdent
    #1

    Hi,

    I need to find the total width of a QTableView and size() is not giving me that so I thought I would add the width of each column.... but where are the columns of a QTableView?? There are no ColumnCount() method....
    How do I find the number of columns in the tableview?

    M 1 Reply Last reply 23 Mar 2024, 00:45
    0
    • J jdent
      23 Mar 2024, 15:52

      @Axel-Spoerl How can I get the vertical scrollbar of the QTableView?

      M Offline
      M Offline
      mpergand
      wrote on 23 Mar 2024, 16:25 last edited by mpergand
      #6

      @jdent said in How do I iterate across the columns of a QTableView so I can find the total width of the table?:

      @Axel-Spoerl How can I get the vertical scrollbar of the QTableView?

      Simply with verticalScrollBar()
      cause QTableView inherits of QAbstractScrollArea ;)

      1 Reply Last reply
      1
      • J jdent
        22 Mar 2024, 22:57

        Hi,

        I need to find the total width of a QTableView and size() is not giving me that so I thought I would add the width of each column.... but where are the columns of a QTableView?? There are no ColumnCount() method....
        How do I find the number of columns in the tableview?

        M Offline
        M Offline
        mpergand
        wrote on 23 Mar 2024, 00:45 last edited by
        #2

        @jdent

        Look at QHeaderView::count()
        for horizontalHeader()

        J 1 Reply Last reply 23 Mar 2024, 01:22
        0
        • M mpergand
          23 Mar 2024, 00:45

          @jdent

          Look at QHeaderView::count()
          for horizontalHeader()

          J Offline
          J Offline
          jdent
          wrote on 23 Mar 2024, 01:22 last edited by jdent
          #3

          @mpergand ok, all I need now is the width of the vertical scrollbar and will be able to calculate what the width of the dialog needs to be!!

          A 1 Reply Last reply 23 Mar 2024, 10:11
          0
          • J JonB referenced this topic on 23 Mar 2024, 09:12
          • J jdent
            23 Mar 2024, 01:22

            @mpergand ok, all I need now is the width of the vertical scrollbar and will be able to calculate what the width of the dialog needs to be!!

            A Offline
            A Offline
            Axel Spoerl
            Moderators
            wrote on 23 Mar 2024, 10:11 last edited by
            #4

            @jdent
            int size() returns the actual size.
            int sizeHint()is probably what you want. It returns how wide the header view wants to be in ideal circumstances.
            int sectionSizeHint(int section)returns the size hint for a given section.

            Software Engineer
            The Qt Company, Oslo

            J 1 Reply Last reply 23 Mar 2024, 15:52
            0
            • A Axel Spoerl
              23 Mar 2024, 10:11

              @jdent
              int size() returns the actual size.
              int sizeHint()is probably what you want. It returns how wide the header view wants to be in ideal circumstances.
              int sectionSizeHint(int section)returns the size hint for a given section.

              J Offline
              J Offline
              jdent
              wrote on 23 Mar 2024, 15:52 last edited by jdent
              #5

              @Axel-Spoerl How can I get the vertical scrollbar of the QTableView?

              M 1 Reply Last reply 23 Mar 2024, 16:25
              0
              • J jdent
                23 Mar 2024, 15:52

                @Axel-Spoerl How can I get the vertical scrollbar of the QTableView?

                M Offline
                M Offline
                mpergand
                wrote on 23 Mar 2024, 16:25 last edited by mpergand
                #6

                @jdent said in How do I iterate across the columns of a QTableView so I can find the total width of the table?:

                @Axel-Spoerl How can I get the vertical scrollbar of the QTableView?

                Simply with verticalScrollBar()
                cause QTableView inherits of QAbstractScrollArea ;)

                1 Reply Last reply
                1
                • J jdent has marked this topic as solved on 23 Mar 2024, 20:14

                5/6

                23 Mar 2024, 15:52

                • Login

                • Login or register to search.
                5 out of 6
                • First post
                  5/6
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved