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. QTableWidget: how to stretch columns?
Forum Updated to NodeBB v4.3 + New Features

QTableWidget: how to stretch columns?

Scheduled Pinned Locked Moved General and Desktop
7 Posts 3 Posters 9.5k 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.
  • ? This user is from outside of this forum
    ? This user is from outside of this forum
    Guest
    wrote on last edited by
    #1

    Hi, I'd like to know how to stretch a QTableWidget's columns from the designer? thanks.

    1 Reply Last reply
    0
    • ? This user is from outside of this forum
      ? This user is from outside of this forum
      Guest
      wrote on last edited by
      #2

      please help.

      1 Reply Last reply
      0
      • Z Offline
        Z Offline
        zeljko
        wrote on last edited by
        #3

        QListWidget doesn't have columns afaik (TextMode). Are you talking about IconMode ? What exactly you want to resize ?

        1 Reply Last reply
        0
        • ? This user is from outside of this forum
          ? This user is from outside of this forum
          Guest
          wrote on last edited by
          #4

          [quote author="zeljko" date="1398791061"]QListWidget doesn't have columns afaik (TextMode). Are you talking about IconMode ? What exactly you want to resize ?[/quote]
          Sorry, I was wrong about the QListWidget: it's in reality about QTableWidget.
          so how to do that?

          1 Reply Last reply
          0
          • Z Offline
            Z Offline
            zeljko
            wrote on last edited by
            #5

            Slots: QTableView::resizeColumnToContents(int: column); and
            QTableView::resizeColumnsToContents();
            is what you are searching for. Don't know if it's possible directly from designer (but since they're slots it should be), but in code it is.

            1 Reply Last reply
            0
            • J Offline
              J Offline
              JvdGlind
              wrote on last edited by
              #6

              I found that you can change all columns by going to tableWidget : QTableWidget -> Header -> horizontalHeaderDefaultSectionSize. However, I did not find a QDesigner way of changing a single column width.

              Jeffrey VAN DE GLIND
              Principle Consultant @ Nalys
              www.nalys-group.com

              1 Reply Last reply
              0
              • P Offline
                P Offline
                pmoglaikar
                wrote on last edited by
                #7

                Hi kaisbs,

                There is way to stretch the column in QTableWidget in Designer also.
                Steps as,

                1. Open the Qt designer.
                2. Select QTableWidget item which you already placed on your form.
                3. See the property box at right hand side.
                4. Scroll down to QTable Widget
                5. Under Header section you will find options to resize it as,
                6. horizontalHeaderDefaultSectionSize increase as you want & try it out
                7. horizontalHeaderStretchLastSection make it true so your empty space after last column will be filled by stretched last column.

                Do your own tryouts on that there are plenty of option to do.

                Thanks
                Prashant Moglaikar

                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