Pergunta

I have a QTreeView on my window and I want to set the following behaviour: columns width must be set to resize to contents, which I have done like this:

tabla->header()->setResizeMode(QHeaderView::ResizeToContents);

Now, what I need to do is set rows to only 1 line, so, if a column contains '\n', they should not be displayed (I have a detailed description dialog to see that).

To sum up, I need to set something like "no multiline" on my treeview.

Any help would be appreciated.

I'd rather not extend qtreeview, since I have a lot of thems and wouldn't like to change them all, but if that's what it takes...

Foi útil?

Solução

QTreeView seems to ignore the newlines in contents when uniformRowHeights is true (seen with Qt-4.8)

This not documented, so normally it shouldn't be relied upon. It would be best to remove the newlines or replace them with spaces when populating the treeview.

Also, I've noticed an exception: if there is only one row in the treeview and it contains a newline, then it gets displayed in two lines, regardless of uniformRowHeights.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top