autoexpanding QTableView columns
I would like my QTableView columns to expand (equally preferably) to fill the width they have available (this one is inside a QStackedWidget but that shouldn't matter I'd think - providing context.).
I can have columns resize to contests, but that isn't the issue. I could also set the size manually but well that just sucks and doesn't expand if/when the user makes the window wider.
A "non-full-width table" looks cheap IMO, and could confuse some of the users :rolleyes: (remember, we don't all get to choose our users' wits level ;) )
Re: autoexpanding QTableView columns
Set the resize mode of the header to "Stretch".
Re: autoexpanding QTableView columns
Thanks. Wish that was an option in Designer. ;)
2 Attachment(s)
Re: autoexpanding QTableView columns
Quote:
Originally Posted by
wysota
Set the resize mode of the header to "Stretch".
Ok. Now how do i set a descent size for all the columns without those ellipses initially such that scrollbars are avoided to the best extent ?
Calling resizeColumnsToContents() and also setting wordWrap to false doesn't help me set initial size :(
Screen shot 1 : The actual result.
Screen shot 2 : The expected result.
Re: autoexpanding QTableView columns
I don't think I understand what you mean. Would you care to explain?
Re: autoexpanding QTableView columns
What i mean to say is,
Now i am getting the dialog in 1st screen shot in which the last column text isn't shown fully (ellipses are shown in the end)
What i want to achieve is the dialog in 2nd screen shot, in which the viewport of the tableview is of proper size to fit all columns without ellipses.
How do i do that ? Calling resizeColumnsToContents still results in the first screen shot.
Re: autoexpanding QTableView columns
You mean you want the dialog to expand itself to fit its contents? It's not an easy thing to do as the table or its header doesn't report a minimum width that would fit its contents. You have to calculate the width yourself and that's the hardest part.
You may also use QHeaderView::setStretchLastColumn(false) and optionally change the resizeMode of columns to ReizeToContents. You'll get scrollbars though...