PDA

View Full Version : Increasing the width of a row in a TreeView



Shambhavi
6th January 2006, 13:15
I am using Qt 4.1's QTreeView. I don't want the text to ellide and hence want to increase the row height based on the text.

In order to do this i am implementing the sizeHint() of QAbstractItemDelgate(), but in this function option.rect.width() return 0. Why is this so?

axeljaeger
6th January 2006, 19:54
I think it is something like the minimum size. You'll have to add the size of your content I think.

graeme
6th January 2006, 22:44
You could try:

resizeColumnToContents ( int column ) (http://doc.trolltech.com/4.1/qtreeview.html#resizeColumnToContents)

graeme

GreyGeek
13th January 2006, 18:13
viewModel->setQuery(queryStr);
if (viewModel->lastError().type() == QSqlError::NoError){
wnui.wholeNameView->setModel(viewModel);
if (viewModel->rowCount() > 0){
for (int i = 0; i < viewModel->rowCount(); ++i)
this->wnui.wholeNameView->verticalHeader()->resizeSection(i,20);
for (int i = 0; i < 7; ++i)
wnui.wholeNameView->resizeColumnToContents(i);