Results 1 to 7 of 7

Thread: Unable to change height of the handle of QSlider

  1. #1
    Join Date
    May 2014
    Posts
    136
    Thanks
    72
    Qt products
    Qt3 Qt4 PyQt3 PyQt4
    Platforms
    MacOS X Windows

    Default Unable to change height of the handle of QSlider

    I am trying to design a QSlider where I need to vary the height of the slider handle based on certain parameters. This is what I have so far:

    Qt Code:
    1. QSlider *fScrollbar = new QSlider(this);
    2. fScrollbar->setGeometry(280,5,10,400);
    3. fScrollbar->setMinimum(5);
    4. fScrollbar->setMaximum(50);
    5. fScrollbar->setTracking(true);
    6. fScrollbar->setStyleSheet("QSlider::handle:vertical { width: 190px; background: black; }");
    To copy to clipboard, switch view to plain text mode 

    This is not working as expected, the handle still defaults to a small height which is not changing. This is what which is appearing:

    slider.jpg

    How do I make it work?

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Unable to change height of the handle of QSlider

    Surely you want to change the height of the vertical slider handle, not the width.

  3. #3
    Join Date
    May 2014
    Posts
    136
    Thanks
    72
    Qt products
    Qt3 Qt4 PyQt3 PyQt4
    Platforms
    MacOS X Windows

    Default Re: Unable to change height of the handle of QSlider

    Sorry, my bad. Yes, I am changing the height of the handle for vertical scrollbar. I was experimenting with horizontal scrollbar as well, I posted that code by mistake. Same result in both cases.

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Unable to change height of the handle of QSlider

    My guess is that the height of a vertical slider handle is tightly controlled by the style plugin or even by the slider itself since it is also used as the indicator how long the scrollable range is.

    Cheers,
    _

  5. #5
    Join Date
    May 2014
    Posts
    136
    Thanks
    72
    Qt products
    Qt3 Qt4 PyQt3 PyQt4
    Platforms
    MacOS X Windows

    Default Re: Unable to change height of the handle of QSlider

    That makes sense. I thought as much. But I found of plenty of websites where it says that this is the way the height of te handle can be varied, so I thought perhaps I am doing something wrong.

  6. #6
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Unable to change height of the handle of QSlider

    It is also possible that to customise a part of QSlider you must customise some other parts or all of it. The examples always seem to customise the groove and handle together:
    http://doc.qt.io/qt-4.8/stylesheet-e...mizing-qslider

  7. The following user says thank you to ChrisW67 for this useful post:

    Cupidvogel (3rd November 2015)

  8. #7
    Join Date
    May 2014
    Posts
    136
    Thanks
    72
    Qt products
    Qt3 Qt4 PyQt3 PyQt4
    Platforms
    MacOS X Windows

    Default Re: Unable to change height of the handle of QSlider

    Yep, that is possible. Will try it out. Thanks!

Similar Threads

  1. QSlider: Increase handle size -> How ?
    By ArneBurghardt in forum Qt Programming
    Replies: 6
    Last Post: 11th August 2016, 20:58
  2. QSlider how to check if slider handle is selected
    By hel in forum Qt Programming
    Replies: 3
    Last Post: 15th May 2014, 08:52
  3. QSlider handle drawing artifacts
    By TheClassic in forum Newbie
    Replies: 3
    Last Post: 27th June 2011, 11:48
  4. How to put custom handle image in QSlider using code?
    By montylee in forum Qt Programming
    Replies: 6
    Last Post: 29th January 2009, 19:38
  5. QSlider custom handle image not displayed
    By planglois in forum Qt Programming
    Replies: 1
    Last Post: 5th September 2008, 13:49

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.