Results 1 to 10 of 10

Thread: few questions related to QTreeWidget

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts

    Default Re: few questions related to QTreeWidget

    How does a grid fit to a tree??

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts

    Default Re: few questions related to QTreeWidget

    Quote Originally Posted by jpn
    How does a grid fit to a tree??
    ...unless there are only top level items and root decoration is set to false, which means you have a multi-column list

    Quote Originally Posted by prakash
    Could you please provide me some sample code ?
    If you use the custom delegate approach proposed by wysota:
    override QItemDelegate:aint()
    Qt Code:
    1. void MyItemDelegate::paint(QPainter* p, const QStyleOptionViewItem &opt, const QModelIndex &idx) const
    2. {
    3. QItemDelegate::paint(p, opt, idx);
    4. if (idx.isValid())
    5. {
    6. p->setPen(Qt::DotLine);
    7. p->drawRect(opt.rect);
    8. }
    9. }
    To copy to clipboard, switch view to plain text mode 
    And the another approach, override QTreeView::drawRow()
    Qt Code:
    1. void MyTreeWidget::drawRow(QPainter* p, const QStyleOptionViewItem &opt, const QModelIndex &idx) const
    2. {
    3. QTreeWidget::drawRow(p, opt, idx);
    4. for (int col = 0; col < columnCount(); ++col)
    5. {
    6. QModelIndex s = idx.sibling(idx.row(), col);
    7. if (s.isValid())
    8. {
    9. QRect rect = visualRect(s);
    10. p->setPen(Qt::DotLine);
    11. p->drawRect(rect);
    12. }
    13.  
    14. }
    15. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by jpn; 10th March 2006 at 08:36.

  3. The following user says thank you to jpn for this useful post:

    razvan.petru (10th November 2009)

Similar Threads

  1. Some questions related to Qt tutorials
    By jamadagni in forum Newbie
    Replies: 2
    Last Post: 17th March 2007, 11:51
  2. resizing a QTreeWidget
    By drhex in forum Qt Programming
    Replies: 6
    Last Post: 27th October 2006, 23:32
  3. QTreeWidget questions
    By fellobo in forum Qt Programming
    Replies: 4
    Last Post: 2nd May 2006, 19:39
  4. Qt related questions and thoughts about getting job
    By AlexKiriukha in forum General Discussion
    Replies: 4
    Last Post: 26th January 2006, 13:25

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
  •  
Qt is a trademark of The Qt Company.