Results 1 to 3 of 3

Thread: Qt 4.3 Style sheet, new features

  1. #1
    Join Date
    Jan 2007
    Location
    Rome
    Posts
    30
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Qt 4.3 Style sheet, new features

    Hi all !

    I'm playing with the new widgets, pseudo-states and sub-controls added in qt 4.3, since the documentations is still lacking I have some questions.

    1) I cannot find a way to define style sheet for the QScrollBar widget, I try redefining its sub-controls.. without any results, someone have made also a simple test ?

    2) I have a problem to define the style sheet for a vertical QSlider, the horizontal one code that I use is:

    Qt Code:
    1. QSlider::groove:horizontal
    2. {
    3. border-image: url(qss/sl_groove.png) 1;
    4. border-width: 1;
    5. height: 1px;
    6. }
    7.  
    8. QSlider::handle:horizontal
    9. {
    10. image: url(qss/h_handle.png);
    11. top: -6px;
    12. }
    To copy to clipboard, switch view to plain text mode 

    the vertical one works visually but I cannot move the handle (it is blocked) (probably something in the code is missing):

    Qt Code:
    1. QSlider::groove:vertical
    2. {
    3. border-image: url(qss/sl_groove_v.png) 1;
    4. border-width: 1;
    5. }
    6.  
    7. QSlider::handle:vertical
    8. {
    9. image: url(qss/v_chandle.png);
    10. }
    To copy to clipboard, switch view to plain text mode 

    3) I don't understand how to set the style sheet of a generic widget (suppose QSlider) and then setting a different style sheet only for a custom widget class derived from the generic one (i.e a ColorSlider that inherit QSlider). The code that I use, without any good result have this form:

    QSlider {
    ......
    }

    ColorSlider {
    ......
    }

    I try to use also several types selector, and I can made a distinction only using the ID Selector (defining the ObjectName for the widget). I would like to define different style sheet for different kind of widgets.

    Best,

    Angelo

  2. #2
    Join Date
    Jan 2007
    Location
    Rome
    Posts
    30
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Question Re: Qt 4.3 Style sheet, new features

    Dear all,
    anyone has tried to style a QScrollBar ?
    I tried different combinations without any good result (also using QDesigner to make the test faster).
    I would like to have some code snippets or some little example...

    Thanks in advance,

    Angelo

  3. #3
    Join Date
    Jan 2006
    Posts
    15
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt 4.3 Style sheet, new features

    Here is how you can style a normal vertical scrollbar. It is not pretty, but I'm sure with some border images it can be tailored according to your taste.

    Qt Code:
    1. QScrollBar::vertical {
    2. background:lightgray;
    3. border-color:black;
    4. border-style:dotted;
    5. width: 15px;
    6. margin-top:16px;
    7. margin-bottom:16px;
    8. }
    9.  
    10. QScrollBar::add-page:vertical,
    11. QScrollBar::sub-page:vertical {
    12. background: none;
    13. }
    14.  
    15. QScrollBar::add-line:vertical{
    16. height: 14px;
    17. background:darkGray;
    18. subcontrol-origin: margin;
    19. subcontrol-position: bottom;
    20. border-color:black;
    21. border-style:solid;
    22. border-width:1px;
    23. }
    24.  
    25. QScrollBar::sub-line:vertical {
    26. subcontrol-origin: margin;
    27. subcontrol-position: top;
    28. height: 14px;
    29. background:darkGray;
    30. border-color:black;
    31. border-style:solid;
    32. border-width:1px;
    33. }
    34.  
    35. QScrollBar::handle:vertical {
    36. background:red;
    37. min-height: 20px;
    38. background:gray;
    39. border-color:black;
    40. border-style:solid;
    41. border-width:1px;
    42. }
    43.  
    44. QScrollBar::add-line:pressed,
    45. QScrollBar::sub-line:pressed,
    46. QScrollBar::handle:pressed{
    47. background:lightgray;
    48. }
    To copy to clipboard, switch view to plain text mode 

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

    Angelo Moriconi (12th June 2007)

Similar Threads

  1. Qt Designer Style Sheet Resources
    By bjoernbg in forum Newbie
    Replies: 1
    Last Post: 24th January 2007, 07:12
  2. How to use style sheet
    By safknw in forum Qt Programming
    Replies: 1
    Last Post: 20th November 2006, 13:05

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.