Results 1 to 14 of 14

Thread: How can I redraw the QTreeWidgetITem?

  1. #1
    Join Date
    Mar 2009
    Location
    Nanjing,China
    Posts
    40
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default How can I redraw the QTreeWidgetITem?

    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

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How can I redraw the QTreeWidgetITem?

    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  3. #3
    Join Date
    Mar 2009
    Location
    Nanjing,China
    Posts
    40
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How can I redraw the QTreeWidgetITem?

    and how to use it?
    I just find this:" use QTreeView and subclass QItemDelegate instead. "

    thanks

  4. #4
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    517
    Thanks
    21
    Thanked 66 Times in 62 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How can I redraw the QTreeWidgetITem?

    you can also use stylesheets for them, that would be much easier..read about them in assistant

  5. #5
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How can I redraw the QTreeWidgetITem?

    Quote Originally Posted by talk2amulya View Post
    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).
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  6. #6
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How can I redraw the QTreeWidgetITem?

    Quote Originally Posted by cspp View Post
    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.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  7. #7
    Join Date
    Mar 2009
    Location
    Nanjing,China
    Posts
    40
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How can I redraw the QTreeWidgetITem?

    I rewrited the drawDisplay,but why the function drawBackground is not virtual?

  8. #8
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    517
    Thanks
    21
    Thanked 66 Times in 62 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How can I redraw the QTreeWidgetITem?

    Quote Originally Posted by spirit View Post
    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..

  9. #9
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How can I redraw the QTreeWidgetITem?

    Quote Originally Posted by talk2amulya View Post
    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.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  10. #10
    Join Date
    Mar 2009
    Location
    Nanjing,China
    Posts
    40
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How can I redraw the QTreeWidgetITem?

    Quote Originally Posted by spirit View Post
    Excuse me,where is the QStyledItemDelegate?I can not find it!

  11. #11
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How can I redraw the QTreeWidgetITem?

    here. (btw, you could click by QStyledItemDelegate and you opened the same page ).
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  12. #12
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How can I redraw the QTreeWidgetITem?

    also you can read this article.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  13. #13
    Join Date
    Mar 2009
    Location
    Nanjing,China
    Posts
    40
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How can I redraw the QTreeWidgetITem?

    Quote Originally Posted by spirit View Post
    also you can read this article.
    I know,In Qt4.3.2,The class QStyledItemDelegate is not exist?
    it just only in Qt4.5?

  14. #14
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How can I redraw the QTreeWidgetITem?

    Quote Originally Posted by cspp View Post
    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.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

Similar Threads

  1. hidden a QTreeWidgetItem
    By mattia in forum Newbie
    Replies: 6
    Last Post: 19th February 2014, 14:04
  2. Custom QTreeWidgetItem context menu?
    By AaronMK in forum Qt Programming
    Replies: 4
    Last Post: 1st February 2010, 04:42
  3. PyQt remove the current QTreeWidgetItem
    By koenux in forum Qt Programming
    Replies: 2
    Last Post: 10th January 2009, 23:08
  4. Replies: 3
    Last Post: 26th April 2008, 18:42
  5. QTreeWidgetItem swap or move up one level problem
    By patrik08 in forum Qt Programming
    Replies: 2
    Last Post: 24th September 2006, 18:34

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.