[Qt-interest] delegate and multi line text
david.jobet at free.fr
david.jobet at free.fr
Mon Oct 19 04:44:28 CEST 2009
Yups, setTextElideMode(Qt::ElideNone) sorta shows the line breaks when the cell has a large enough width.
When the width is not large enough, then qt wraps at word boundaries.
So if I was showing the content of my columns as is, it would be OK.
Interestingly, in the delegate, when I disable elide mode and use the style to draw the contents, it still shows funny character instead of the '\t' and '\n' and does not obey at all the line breaks.
I guess I'm doing something wrong, but what ?
Here's what I do :
void PatchContentDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
QString text = ustensilePatchView_.model()->data(index).toString() + "\n\n" + ustensilePatchView_.model()->data(index.sibling(index.row(), PatchLister::Files)).toString();
QStyleOptionViewItemV4 opt = option;
initStyleOption(&opt, index);
QStyle &style = *QApplication::style();
opt.text = text;
style.drawControl(QStyle::CE_ItemViewItem, &opt, painter, 0);
}
David
----- Mail d'origine -----
De: david jobet <david.jobet at free.fr>
À: qt-interest at trolltech.com
Envoyé: Sun, 18 Oct 2009 16:51:14 +0200 (CEST)
Objet: Re: [Qt-interest] delegate and multi line text
Well, it won't solve my issue : I have a model that has 6 columns, but I want to show only 5 in my view by merging the content of 2 columns into one.
I can do that with a proxy or with a delegate.
I prefer the delegate because I think it is lighter and it's really a view problem : I'm not filtering, adding or removing stuff from the model : I'm really just trying to improve the lisibility of the row by merging two things together.
So I hide a column from my view and use a custom delegate to display the content of the 2 columns into one.
Anyway, before doing that, I wasn't seeing the line breaks in my 2 original columns.
I haven't tried to disable the elide mode, but looking at qt's code, it really seems like everything is either not wrapped (wrap mode = Manual) : it shows up in 1 line only, or wrapped, and in that case it does shows up on multiple lines, but the problem is the wrap mode default to 'word' internally and I don't see how I can say I want a 'line break' wrap mode.
I'll give it a try anyway.
Any other ideas ?
David
----- Mail d'origine -----
De: Jan <janusius at gmx.net>
À: qt-interest at trolltech.com
Envoyé: Sat, 17 Oct 2009 12:55:03 +0200 (CEST)
Objet: Re: [Qt-interest] delegate and multi line text
Hi,
Isn't the default delegate supporting line breaks? AFAIK you can set the
elide mode to "Non" and if you do not fix rowsize the delegate should
display line breaks.
Jan
_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest
_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest
More information about the Qt-interest-old
mailing list