Results 1 to 5 of 5

Thread: Creating gaps between QTreeWidgetItems

  1. #1
    Join Date
    Sep 2009
    Location
    Aachen, Germany
    Posts
    60
    Thanks
    2
    Thanked 7 Times in 7 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Creating gaps between QTreeWidgetItems

    Hi there,

    I'm working on a quite individual version of QTreeWidget. Certain items have certain looks, sizes and gaps between them.
    I reimplemented QSyteldItemDelegate for the looks, and so far I also use it to create the gaps by adjusting the size of the item via my delegates sizeHint() to fit what my paint() implementation paints plus the gap.
    That kind of works, but doesn't look good as the branches stop where the gaps begin and so on.

    Is there any way to give a QTreeWidgetItem a top- and bottom-spacing, so there actually is a gap between the items?

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Creating gaps between QTreeWidgetItems

    is there any subsection for drawing text ??
    may be a proper combination of text rect, and item rect will help you achieve what you want.

  3. #3
    Join Date
    Jan 2006
    Location
    Knivsta, Sweden
    Posts
    153
    Thanks
    30
    Thanked 13 Times in 12 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: Creating gaps between QTreeWidgetItems

    Have you tried calling setItemDelegate() on your QTreeWidget to your own subclassed ItemDelegate which has a method like

    Qt Code:
    1. QSize sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index ) const
    2. {
    3. QSize mysize(QItemDelegate::sizeHint(option, index));
    4. mysize.setHeight( /* your own height */ );
    5. return mysize;
    6. }
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Sep 2009
    Location
    Aachen, Germany
    Posts
    60
    Thanks
    2
    Thanked 7 Times in 7 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Creating gaps between QTreeWidgetItems

    To quote myself:
    I reimplemented QSyteldItemDelegate for the looks, and so far I also use it to create the gaps by adjusting the size of the item via my delegates sizeHint() to fit what my paint() implementation paints plus the gap.
    That kind of works, but doesn't look good as the branches stop where the gaps begin and so on.

  5. #5
    Join Date
    Jan 2006
    Location
    Knivsta, Sweden
    Posts
    153
    Thanks
    30
    Thanked 13 Times in 12 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: Creating gaps between QTreeWidgetItems

    Alright, I ought to read more than the last sentence

    But if you can control the height and have your own paint(), then surely you can make all the pixels look the way you want them to? Could you perhaps provide a drawing of what you get vs what you'd like instead?

Similar Threads

  1. Problem in creating thread in GUI application
    By jyoti kumar in forum Qt Programming
    Replies: 2
    Last Post: 15th May 2006, 13:05

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.