PDA

View Full Version : TextItems in QTreeview are showing "..." if resized (instead of a horz. scrollbar)



nightghost
14th October 2009, 15:18
Hello,

I'm using a QTreeView to show data. Everything is fine. Excepted for one thing. Instead of showing a showing a horizontal scrollbar if the treeview is resized the text is shortened and shows "..." at the end (see the last four item in the example).

Example:
http://www.qtcentre.org/forum/attachment.php?attachmentid=3745&stc=1&d=1255526090
(The horizontal scrollbar is shown, because i used setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn );, but it is useless as seen on the screenshot)

I'm using the default delegate with a custom model. How can I get a working scrollbar instead of "..."

Lykurg
15th October 2009, 15:52
Hi,

use
QTreeView *treeView;
treeView->setTextElideMode(Qt::ElideNone);

nightghost
15th October 2009, 18:08
Ah nice. The "..." are gone. But the horizontal scrollbar is still unusable.

http://www.qtcentre.org/forum/attachment.php?attachmentid=3747&stc=1&d=1255622759

Lykurg
15th October 2009, 22:34
then you also have to use:

view->header()->setResizeMode(0, QHeaderView::ResizeToContents);
view->header()->setStretchLastSection(false);
It only might look "ugly" if you show the header because not the whole width is covered by the header.

nightghost
16th October 2009, 10:19
Ah great it working. Thanks.

A hint: Its only working if the methods are called AFTER the model is inserted into the QTreeView. Otherwise the colunm will be resized only one time.