PDA

View Full Version : columns in QTableView don't auto stretch



aresa
27th December 2013, 14:41
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!

hind
22nd January 2014, 03:59
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?