PDA

View Full Version : How can I redraw the QTreeWidgetITem?



cspp
14th May 2009, 08:11
I used the QTreeWidget to show some record,
Now I want the record displayed more beautiful,like the background color,foreground color,and I also want to draw the border as the item.
and how can i do,which function should be rewrited?
thax:)

spirit
14th May 2009, 08:16
take a look at QItemDelegate & QStyledItemDelegate.

cspp
14th May 2009, 08:49
and how to use it?
I just find this:" use QTreeView and subclass QItemDelegate instead. "

thanks

talk2amulya
14th May 2009, 09:07
you can also use stylesheets for them, that would be much easier..read about them in assistant

spirit
14th May 2009, 11:14
you can also use stylesheets for them, that would be much easier..read about them in assistant
but not so effective (I mean a performance). ;)

spirit
14th May 2009, 11:16
and how to use it?
I just find this:" use QTreeView and subclass QItemDelegate instead. "

thanks
take a look at QItemDelegate::drawBackground, QItemDelegate::drawCheck, QItemDelegate::drawDecoration, QItemDelegate::drawDisplay, QItemDelegate::drawFocus and QItemDelegate:: paint.

cspp
14th May 2009, 11:35
I rewrited the drawDisplay,but why the function drawBackground is not virtual?

talk2amulya
14th May 2009, 12:13
but not so effective (I mean a performance). ;)

i'd disagree with that, the performance hit(if any) is going to be inconsiderable..plus when you use css for all this stuff..u can change the look and feel of your application WITHOUT recompiling your whole application..and in his case, the changes he wants requires a 5-6 line css..i dont see a real harm in that..i guess its just preferences of people..today's machines are fast enough..and its just the demographic of application that you are targetting which should be bore in mind before you take these implementation decisions..people should be provided with all options possible, with respective pros and cons, and let them decide..but thats just me..

spirit
14th May 2009, 12:16
i'd disagree with that, the performance hit(if any) is going to be inconsiderable..plus when you use css for all this stuff..u can change the look and feel of your application WITHOUT recompiling your whole application..and in his case, the changes he wants requires a 5-6 line css..i dont see a real harm in that..i guess its just preferences of people..today's machines are fast enough..and its just the demographic of application that you are targetting which should be bore in mind before you take these implementation decisions..people should be provided with all options possible, with respective pros and cons, and let them decide..but thats just me..
ok, lets imagine that you have css-file with 20 line (or more), for parsing this script Qt takes some time, but if you implement a deletegate it will work much faster then ccs stlye.

cspp
14th May 2009, 12:41
take a look at QItemDelegate & QStyledItemDelegate.

Excuse me,where is the QStyledItemDelegate?I can not find it!:(:confused:

spirit
14th May 2009, 12:42
here (http://doc.trolltech.com/4.5/qstyleditemdelegate.html). (btw, you could click by QStyledItemDelegate and you opened the same page :) ).

spirit
14th May 2009, 12:43
also you can read this (http://doc.qtsoftware.com/qq/qq24-delegates.html) article.

cspp
14th May 2009, 12:46
also you can read this (http://doc.qtsoftware.com/qq/qq24-delegates.html) article.

I know,In Qt4.3.2,The class QStyledItemDelegate is not exist?
it just only in Qt4.5?

spirit
14th May 2009, 12:50
In Qt4.3.2,The class QStyledItemDelegate is not exist?

unfortunately, this class was introduced in Qt 4.4.


This class was introduced in Qt 4.4.