Results 1 to 7 of 7

Thread: resizing a QTreeWidget

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: resizing a QTreeWidget

    Quote Originally Posted by drhex View Post
    Is there any way to ask Qt about these numbers?
    "2" for the spacing between columns
    Probably not.

    "16" for the width of a scrollbar
    verticalScrollbar()->width() should do the trick. Just check if the scrollbar should be visible at all.

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

    Default Re: resizing a QTreeWidget

    Just check if the scrollbar should be visible at all.
    ...by knowing how many item one wants to show and how much space each
    of them will use up and how much space there is available, I presume.

    Qt doesn't seem to know [whether a scrollbar is needed] by the time sizeHint is called;
    The scrollbar width() always returns 100 there, it changes into 16 once it is actually rendered on screen.

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: resizing a QTreeWidget

    Quote Originally Posted by drhex View Post
    ...by knowing how many item one wants to show and how much space each
    of them will use up and how much space there is available, I presume.
    I don't know is such assumptions are appropriate. Calling verticalScrollBar()->isVisible() might be more reliable.

    Qt doesn't seem to know [whether a scrollbar is needed] by the time sizeHint is called;
    That doesn't matter. You can change the size hint once the widget is rendered for the first time using QWidget::updateGeometry().
    The scrollbar width() always returns 100 there, it changes into 16 once it is actually rendered on screen.
    Yes, that's normal for every widget.

  4. The following user says thank you to wysota for this useful post:

    drhex (1st October 2006)

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

    Default Re: resizing a QTreeWidget

    Just found a way to get the size of the scrollbar without having to display one first

    Qt Code:
    1. qApp->style()->pixelMetric(QStyle::PM_ScrollBarExtent)
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Replies: 1
    Last Post: 21st September 2006, 10:37
  2. QTreeWidget & QListWidget different selection
    By munna in forum Qt Programming
    Replies: 9
    Last Post: 21st July 2006, 06:50
  3. How to capture resizing of QTreeWidget columns?
    By simk in forum Qt Programming
    Replies: 2
    Last Post: 27th April 2006, 06:10
  4. QTreeWidget problem!!
    By mcenatie in forum Qt Programming
    Replies: 2
    Last Post: 10th March 2006, 11:47
  5. few questions related to QTreeWidget
    By prakash in forum Qt Programming
    Replies: 9
    Last Post: 10th March 2006, 07:32

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.