Results 1 to 3 of 3

Thread: How to determine scrollbar width?

  1. #1
    Join Date
    Oct 2009
    Posts
    27
    Thanks
    4
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default How to determine scrollbar width?

    How can I find out how wide a scrollbar is at runtime?

    I have a table that is sized to perfectly display the contents. Once there is enough items to show a scrollbar, it overlaps my content.

    I would like to be able to query the scrollbar width, based on the current style, so that I can make my widget exactly wide enough to accommodate the scrollbar should it appear.

    Thank!

  2. #2
    Join Date
    Feb 2007
    Location
    Karlsruhe, Germany
    Posts
    469
    Thanks
    17
    Thanked 90 Times in 88 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to determine scrollbar width?

    Hi!

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

    Happy coding!

    Johannes

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

    bibbinator (6th April 2011)

  4. #3
    Join Date
    Oct 2009
    Posts
    27
    Thanks
    4
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: How to determine scrollbar width?

    Thanks for that.

    Cheers!

Similar Threads

  1. How do I determine if a QTableWidget's scrollbar is visible?
    By fuzzywuzzy01 in forum Qt Programming
    Replies: 3
    Last Post: 23rd February 2012, 16:42
  2. vertical scrollbar subtraction from the screen width
    By sujan.dasmahapatra in forum Qt Programming
    Replies: 0
    Last Post: 16th February 2011, 09:16
  3. Replies: 1
    Last Post: 9th February 2010, 15:04
  4. QToolBox width fixed to maximum content width
    By ghorwin in forum Qt Programming
    Replies: 0
    Last Post: 10th July 2009, 09:58
  5. vertical scrollbar width
    By drkbkr in forum Qt Programming
    Replies: 25
    Last Post: 31st May 2008, 07:09

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.