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. [Solved] Setting size of QTableView Header
Forum Updated to NodeBB v4.3 + New Features

[Solved] Setting size of QTableView Header

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 6.3k 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.
  • A Offline
    A Offline
    amban
    wrote on last edited by
    #1

    Hi,
    I have created a QTableView with QStandardItemModel. I have set the header as follows:
    @
    QString headerlist ;
    headerlist << c1 << c12<< c123;
    mytable->setHorizontalHeaderLabels(headerlist);
    @

    I want to set my header size on the basis of size of string in headerlist. E.g. here size of col1 is 2 , col2 is 3 ...and so on....
    Please suggest a way to do it. I see resizeSection() as one of the solutions. Is there any other way ?

    Thanks

    1 Reply Last reply
    0
    • A Offline
      A Offline
      aureshinite
      wrote on last edited by
      #2

      Try:

      @table->resizeColumnsToContents();@

      If the data get out of display area, it will add scrolls. If you also want the table to adjust to display all the columns, you need to do a bit more.

      1 Reply Last reply
      0
      • A Offline
        A Offline
        amban
        wrote on last edited by
        #3

        Hey Thanks,
        I think this is good for me.

        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