Results 1 to 3 of 3

Thread: Customizing QScrollBar sub-controls inside QTextEdit with style sheets

  1. #1
    Join Date
    Nov 2007
    Posts
    5
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Customizing QScrollBar sub-controls inside QTextEdit with style sheets

    Simply put, how can I customize the visible down arrow, up arrow, the handle etc. of a QScrollBar using style sheets? I've read the documentation, but it isn't quite sufficient enough for me.

    I was able to change the background color of a QTextEdit, the color of a QPushButton. I was also able to change the arrow image of a QComboBox (QComboBox::drop-down subcontrol) as shown in the documentation. But I cannot seem to be able to affect the QScrollBar subcontrols inside the QTextEdit. I was able to change the background-color of the scroll bar inside the text edit, so I guess I should be close, but... The documentation states that if one wants to customize one subcontrol, one has to customize them all. So here's the style sheet I was trying out. If someone could post a simple, complete style sheet that visibly changes one sub-control of a QScrollBar, I'd be grateful.

    Qt Code:
    1. {
    2. background: red;
    3. }
    4. {
    5. background: black;
    6. }
    7. QComboBox::drop-down
    8. {
    9. image: url(:/icon/arrow_down);
    10. }
    11. {
    12. }
    13. QScrollBar::up-arrow
    14. {
    15.  
    16. }
    17. QScrollBar::down-arrow
    18. {
    19. image: url(:/icon/arrow_down);
    20. }
    21. QScrollBar::left-arrow
    22. {
    23.  
    24. }
    25. QScrollBar::right-arrow
    26. {
    27.  
    28. }
    29. QScrollBar::add-line
    30. {
    31.  
    32. }
    33. QScrollBar::add-page
    34. {
    35. }
    36. QScrollBar::down-button
    37. {
    38. image: url(:/icon/arrow_down);
    39. }
    40. QScrollBar::handle
    41. {
    42.  
    43. }
    44. QScrollBar::sub-line
    45. {
    46.  
    47. }
    48. QScrollBar::sub-page
    49. {
    50.  
    51. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Mar 2008
    Location
    France
    Posts
    149
    Thanks
    2
    Thanked 21 Times in 21 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Customizing QScrollBar sub-controls inside QTextEdit with style sheets

    You're right, you have to use subcontrols an attributes to customize a widget through style sheet.
    You still seem a bit confused about how style sheet works. I would recommend your to read the documentation once more time to get a good grasp of the mechanism.
    Especially, have look at those links :
    http://doc.trolltech.com/4.3/stylesh...ing-qscrollbar
    http://doc.qt.nokia.com/4.6/stylesheet-reference.html
    http://doc.qt.nokia.com/4.6/styleshe...f-sub-controls
    Last edited by toutarrive; 3rd April 2010 at 15:17.

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

    Kimmo (3rd April 2010)

  4. #3
    Join Date
    Nov 2007
    Posts
    5
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Customizing QScrollBar sub-controls inside QTextEdit with style sheets

    Thanks! I've been reading about this for so many hours I apparently completely missed the complete example that demonstrates the style sheets for QScrollBar. This helps a lot.

    Thanks again.

Similar Threads

  1. Do Qt Style Sheets support List-style-image?
    By daiheitan in forum Qt Programming
    Replies: 6
    Last Post: 12th March 2010, 01:41
  2. customizing QScrollbar
    By MarkoSan in forum Qt Programming
    Replies: 7
    Last Post: 15th October 2009, 18:51
  3. QTextEdit and style sheets
    By roxton in forum Qt Programming
    Replies: 2
    Last Post: 13th September 2008, 13:33
  4. Qt style sheets
    By locus in forum Qt Programming
    Replies: 5
    Last Post: 5th April 2007, 17:03
  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.