PDA

View Full Version : Elide modes for QTreeView ,QStandardItemModel



kiran p
30th March 2011, 12:34
Hello Everyone,

I've come across a challenge when Using model view Architecture (QTreeView ,QStandardItemModel)
where in i need to set different Elide modes for different columns in a tree view
for eg column 1 setTextElideMode(Qt::ElideRight);
column 2 setTextElideMode(Qt::ElideLeft);
column 3 setTextElideMode(Qt::ElideMiddle);

Please respond! thanks in advance..

wysota
30th March 2011, 12:38
You can use different modes by using a custom delegate. Subclass QStyledItemDelegate or QItemDelegate and use different values for different columns of the model. QFontMetrics::elidedText() will help you.

kiran p
30th March 2011, 13:05
will you please provide little finer information on implementation basis(development) i am new to GUI development.
thanks in advance

wysota
30th March 2011, 13:22
Have a look at QStyledItemDelegate::paint() and QStyleOptionViewItem. All you need to do is to set the text elide mode of the option you are given based on the column of the index and call the base class implementation with the modified option.

kiran p
1st April 2011, 10:34
Its working Thank you very much :)