Results 1 to 2 of 2

Thread: columns in QTableView don't auto stretch

  1. #1
    Join Date
    Oct 2013
    Posts
    6
    Thanks
    1
    Thanked 3 Times in 3 Posts

    Default columns in QTableView don't auto stretch

    i need one column of my QTableView object to stretch to its contents, while the height of every row is fixed.
    simply put, i want all text in column 1 be fully displayed in only one row, no word wrap, no ellipsis.
    i tried
    m_tableView->verticalHeader()->setSectionResizeMode(QHeaderView::Fixed);
    m_tableView->horizontalHeader()->setSectionResizeMode(1, QHeaderView::ResizeToContents);
    but the above codes sometimes work while sometimes don't work(with ellipsis at the right most).

    FYI, when the text is displayed with ellipsis and i drag any section slightly a little larger or smaller, ellipsis in column 1 will suddenly disappear and column 1 is auto-stretched to the text.

    i respect any response, thank you!

  2. #2
    Join Date
    Mar 2013
    Posts
    28
    Thanks
    13
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: columns in QTableView don't auto stretch

    I'm having similar problem.
    I've made the whole horizontal header resize to contents. It seems working with the first visible part, but when I scroll down I can find cells that contain longer strings with ellipsis. It seems that the resizing only takes care of the first visible part for display. I've tried QTableView::resizeColumnsToContents and no luck.
    BTW I'm working on 4.8.4. Maybe it's solved later?

Similar Threads

  1. Sorting columns of the QTableView
    By Qiieha in forum Qt Programming
    Replies: 8
    Last Post: 9th May 2011, 19:24
  2. QTableView and auto scroll
    By ranna in forum Qt Programming
    Replies: 0
    Last Post: 23rd March 2009, 13:02
  3. updating QTableView with new qsl columns
    By sylvainb in forum Qt Programming
    Replies: 2
    Last Post: 28th January 2009, 20:51
  4. Don't resize columns - QTableView
    By estanisgeyer in forum Qt Programming
    Replies: 1
    Last Post: 26th January 2009, 16:59
  5. autoexpanding QTableView columns
    By ucntcme in forum Qt Programming
    Replies: 6
    Last Post: 11th March 2008, 09:28

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.