Results 1 to 8 of 8

Thread: customizing QScrollbar

  1. #1
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Thanks
    111
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default customizing QScrollbar

    Hi to all!

    I subclassed QScrollBar but now I have two questions:

    1. How do I repaint slider with some texture (I've made texture using photoshop and converted it to .png file)
    2. How do I repaint both arrows with custom shape/custom picture?

    Is it right way to reimplement paintEvent()?
    Qt 5.3 Opensource & Creator 3.1.2

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

    Default Re: customizing QScrollbar

    The answer is: don't subclass but use style sheets.
    J-P Nurmi

  3. #3
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Thanks
    111
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: customizing QScrollbar

    Ok, but I want to do it hard way!!!!!
    Qt 5.3 Opensource & Creator 3.1.2

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

    Default Re: customizing QScrollbar

    Quote Originally Posted by MarkoSan View Post
    Ok, but I want to do it hard way!!!!!
    Well, good luck. Take a look at QScrollBar::paintEvent() implementation. It's all done with styles. You might be able to change the background brush with palettes but for custom arrow controls you'll need a custom style. At least if you want to do it the right way (tm).
    J-P Nurmi

  5. #5
    Join Date
    Jul 2009
    Posts
    39
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: customizing QScrollbar

    Quote Originally Posted by jpn View Post
    The answer is: don't subclass but use style sheets.
    I used style sheet, but it does not look very good, and also examples in qt documentation don't seem enough. http://doc.trolltech.com/4.4/stylesh...ing-qscrollbar

    Do you have any good examples of style sheet applied on QScroolBar?

    Thanks.

  6. #6
    Join Date
    Jan 2006
    Location
    Frankfurt
    Posts
    500
    Thanks
    1
    Thanked 52 Times in 52 Posts
    Platforms
    MacOS X Unix/X11

    Default Re: customizing QScrollbar

    Do it using a QStyle, it is hard enough.
    It's nice to be important but it's more important to be nice.

  7. #7
    Join Date
    Jul 2009
    Posts
    39
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: customizing QScrollbar

    Quote Originally Posted by axeljaeger View Post
    Do it using a QStyle, it is hard enough.
    Do you have any suggestion for changing the appearance of QScrollBar?

  8. #8
    Join Date
    Jan 2006
    Location
    Frankfurt
    Posts
    500
    Thanks
    1
    Thanked 52 Times in 52 Posts
    Platforms
    MacOS X Unix/X11

    Default Re: customizing QScrollbar

    Reimplement drawComplexControl and watch out for CC_ScrollBar
    It's nice to be important but it's more important to be nice.

Similar Threads

  1. QScrollbar Stylesheets problems in Qt4.4
    By GuS in forum Qt Programming
    Replies: 2
    Last Post: 6th September 2008, 20:37
  2. Problems styling QScrollBar / QPushButton
    By December in forum Qt Programming
    Replies: 0
    Last Post: 20th January 2008, 06:53
  3. customizing table widget
    By krishna.bv in forum Qt Programming
    Replies: 1
    Last Post: 25th January 2007, 13:43
  4. Replies: 2
    Last Post: 17th July 2006, 20:09
  5. Customizing QScrollBar
    By Jimmy2775 in forum Qt Programming
    Replies: 2
    Last Post: 2nd February 2006, 18:01

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.