Page 1 of 2 12 LastLast
Results 1 to 20 of 35

Thread: QScrollbar stylesheet

  1. #1
    Join Date
    Mar 2006
    Location
    Argentina - CABA
    Posts
    66
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Platforms
    Unix/X11

    Default QScrollbar stylesheet

    Hi guys!!

    I am having doubs about some parts of the stylesheet of a scrollbar, and i was reading the docs from: http://doc.trolltech.com/main-snapsh...ing-qscrollbar

    I've managed to style most of it, but some parts I don't understand how to do it. Lets see the example:



    How I do style those missing parts?

    My stylesheet code is:

    QScrollBar:vertical { \
    background-image: url(:/Styles/styles/scrollbar_bg.png); \
    width: 15px; \
    margin: 15px 0 15px 0;} \
    QScrollBar::handle:vertical { \
    background-image: url(:/Styles/styles/scrollbar_body.png); \
    min-height: 15px;} \
    QScrollBar::add-line:vertical { \
    border: 0px; \
    background-image: url(:/Styles/styles/scrollbar_downArrow_Bg.png); \
    height: 15px; \
    subcontrol-position: bottom; \
    subcontrol-origin: margin;} \
    QScrollBar::sub-line:vertical { \
    border: 0px; \
    background-image: url(:/Styles/styles/scrollbar_upArrow_Bg.png); \
    height: 15px; \
    subcontrol-position: top; \
    subcontrol-origin: margin;} \
    QScrollBar::up-arrow:vertical { \
    background-image: url(:/Styles/styles/scrollbar_upArrow.png); \
    background-repeat: no repeat; \
    width: 15px; \
    height: 15px;} \
    QScrollBar::down-arrow:vertical { \
    background-image: url(:/Styles/styles/scrollbar_downArrow.png); \
    background-repeat: no repeat; \
    width: 15px; \
    height: 15px;} \
    QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical { \
    background: none;}
    Thanks!!
    Gustavo A. DÃ*az
    artistic.gdnet.com.ar

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QScrollbar stylesheet

    What do you mean by "missing" parts?

  3. #3
    Join Date
    Mar 2006
    Location
    Argentina - CABA
    Posts
    66
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Platforms
    Unix/X11

    Default Re: QScrollbar stylesheet

    You don't see the pixmap?

    Is how i do style those "parts"...

    Look at the image.. and you will see that when you style a scrollbar have many splitted image parts.. so, from the handle... I don't know how to style the top and bottom part.. and the grip is the middle of that handle (example, 3 lines.. or dots.. or whatever)

    Thanks...
    Last edited by GuS; 1st December 2007 at 16:13.
    Gustavo A. DÃ*az
    artistic.gdnet.com.ar

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QScrollbar stylesheet

    You mean the parts that are white on the picture? They are styled by the scrollbar itself. Your QScrollBar:vertical { ... } rule should catch it. Try setting background:red; and you'll see for yourself.

  5. #5
    Join Date
    Mar 2006
    Location
    Argentina - CABA
    Posts
    66
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Platforms
    Unix/X11

    Default Re: QScrollbar stylesheet

    Quote Originally Posted by wysota View Post
    You mean the parts that are white on the picture? They are styled by the scrollbar itself. Your QScrollBar:vertical { ... } rule should catch it. Try setting background:red; and you'll see for yourself.
    No man.... besides.. white? lol... is grey.. and that is styled allready, which is the background of the entire scrollbar..........
    Look at the handle... should have top and bottom rounded little images there...
    One:
    Second:

    So, top and bottom of the handle... to finish it rounded.......

    And the Grip.. is what goes in the middle of the scroll handle...
    Gustavo A. DÃ*az
    artistic.gdnet.com.ar

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QScrollbar stylesheet

    Yes, I know what a grip is, but I'm not a sightseer, so don't expect me to understand what you want if you give me an image with some things pointed out and ask about "missing" things. How did you expect me to guess what your goal was? You should have told me you want the handle to be rounded or something.

    Use border-image on the ::handle sub-control - provide it with an image that can be cut into 9 parts and provide cut sizes for it. The middle parts will be stretched or repeated (depending on your settings) and corners will be applied without any scaling to prevent distortions.

    See the attachment for a result.
    Attached Images Attached Images
    Last edited by wysota; 1st December 2007 at 21:55.

  7. #7
    Join Date
    Mar 2006
    Location
    Argentina - CABA
    Posts
    66
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Platforms
    Unix/X11

    Default Re: QScrollbar stylesheet

    Quote Originally Posted by wysota View Post
    Yes, I know what a grip is, but I'm not a sightseer, so don't expect me to understand what you want if you give me an image with some things pointed out and ask about "missing" things. How did you expect me to guess what your goal was? You should have told me you want the handle to be rounded or something.
    No, is no t the same.. you didn't interpreted well the pixmap... to be rounded... is TO MUCH round... every scrollbar should have a top and bottom pixmap... and i was very clear

    I will make some test on it... is easy.. i just need to know the controls to add those pixmaps on the scroll... cause the rest.. i've already done it.
    Gustavo A. DÃ*az
    artistic.gdnet.com.ar

  8. #8
    Join Date
    Aug 2007
    Posts
    39
    Thanks
    8

    Default Re: QScrollbar stylesheet

    GuS, I got what you meant in the first post. Have you tried adding the "rounded" part to the sub-page and add-page images? I haven't tried it, so it might not work, but if the sub-page image was a really long, grey image, with a small "rounded" part at the top, then it would look like the scrollbar handle was rounded.

  9. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QScrollbar stylesheet

    Quote Originally Posted by GuS View Post
    No, is no t the same.. you didn't interpreted well the pixmap... to be rounded... is TO MUCH round... every scrollbar should have a top and bottom pixmap... and i was very clear
    Obviously you have to use your own pixmap, not my crude-example-cut-off-from-a-picture-downloaded-from-net one.

  10. #10
    Join Date
    Mar 2006
    Location
    Argentina - CABA
    Posts
    66
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Platforms
    Unix/X11

    Default

    Quote Originally Posted by ihoss View Post
    GuS, I got what you meant in the first post. Have you tried adding the "rounded" part to the sub-page and add-page images? I haven't tried it, so it might not work, but if the sub-page image was a really long, grey image, with a small "rounded" part at the top, then it would look like the scrollbar handle was rounded.
    See? i was clear.. then you styled scrollbars somewhere
    I mean, is not the first time i do this... i did it in aMSN skin when i was styling.

    I will try that... but i think i already tried to use add page and subpage and i saw no effect... or maybe i did wrong.

    Example code? please?


    Thanks!!

    Quote Originally Posted by wysota View Post
    Yes, I know what a grip is, but I'm not a sightseer, so don't expect me to understand what you want if you give me an image with some things pointed out and ask about "missing" things. How did you expect me to guess what your goal was? You should have told me you want the handle to be rounded or something.

    Use border-image on the ::handle sub-control - provide it with an image that can be cut into 9 parts and provide cut sizes for it. The middle parts will be stretched or repeated (depending on your settings) and corners will be applied without any scaling to prevent distortions.

    See the attachment for a result.
    By the way, can you show me a example stylesheet code of what you mean?
    Thanks.
    Last edited by wysota; 2nd December 2007 at 12:38. Reason: Merged two posts
    Gustavo A. DÃ*az
    artistic.gdnet.com.ar

  11. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QScrollbar stylesheet

    Here is an article about border-image:
    http://www.css3.info/preview/border-image/

    As for the stylesheet you should use, it's more or less like this:
    css Code:
    1. QScrollBar::handle:vertical {
    2. border-image: url('someimage.png') 0 2 0 2;
    3. border-top: 2px;
    4. border-bottom: 2px;
    5. }
    To copy to clipboard, switch view to plain text mode 

  12. #12
    Join Date
    Mar 2006
    Location
    Argentina - CABA
    Posts
    66
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Platforms
    Unix/X11

    Default Re: QScrollbar stylesheet

    Quote Originally Posted by wysota View Post
    Here is an article about border-image:
    http://www.css3.info/preview/border-image/

    As for the stylesheet you should use, it's more or less like this:
    css Code:
    1. QScrollBar::handle:vertical {
    2. border-image: url('someimage.png') 0 2 0 2;
    3. border-top: 2px;
    4. border-bottom: 2px;
    5. }
    To copy to clipboard, switch view to plain text mode 
    This didn't worked...
    Gustavo A. DÃ*az
    artistic.gdnet.com.ar

  13. #13
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QScrollbar stylesheet

    Did you assemble a proper border image from your three images? And did you read the docs in Qt stylesheets reference about border-image? I might have mixed up the order of parameters.

  14. #14
    Join Date
    Mar 2006
    Location
    Argentina - CABA
    Posts
    66
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Platforms
    Unix/X11

    Default Re: QScrollbar stylesheet

    Quote Originally Posted by wysota View Post
    Did you assemble a proper border image from your three images? And did you read the docs in Qt stylesheets reference about border-image? I might have mixed up the order of parameters.
    Yes i did, i read all the references... but i think this is not the approach i need.. i just need to put those images (One and Second as i showed you) one on top... another in bottom...
    Gustavo A. DÃ*az
    artistic.gdnet.com.ar

  15. #15
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QScrollbar stylesheet

    This is exactly what border-image does... Just give me your assembled image (paste it as an attachment to your post) and I'll prepare you the code needed.

  16. #16
    Join Date
    Mar 2006
    Location
    Argentina - CABA
    Posts
    66
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Platforms
    Unix/X11

    Default Re: QScrollbar stylesheet

    Quote Originally Posted by wysota View Post
    This is exactly what border-image does... Just give me your assembled image (paste it as an attachment to your post) and I'll prepare you the code needed.
    You have already those images.. look some post up... ("One" and "Second", the fifth post)
    Gustavo A. DÃ*az
    artistic.gdnet.com.ar

  17. #17
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QScrollbar stylesheet

    I need a single image containing three parts - top, middle and bottom. Not two images without the middle part - it won't work that way.

  18. #18
    Join Date
    Mar 2006
    Location
    Argentina - CABA
    Posts
    66
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Platforms
    Unix/X11

    Default Re: QScrollbar stylesheet

    Quote Originally Posted by wysota View Post
    I need a single image containing three parts - top, middle and bottom. Not two images without the middle part - it won't work that way.
    Ok, so the bg of the scroll handle...

    Here you go:

    Scroll Top:
    Scroll bg (middle):
    Scroll Bottom:
    Gustavo A. DÃ*az
    artistic.gdnet.com.ar

  19. #19
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QScrollbar stylesheet

    Why do you keep ignoring what I'm telling you? I asked for a single image consisting of the three images composed into one and I asked you to attach it to your post. We don't like when people use 3rd party sites to link to images, because then they tend to remove the images and we're left with dangling links and when other people have similar problems, they can't trace the thread because of missing links.

    Anyway, here is your stylesheet. I only include the part that is different from the stylesheet in the example about styling QScrollBar in the manual.

    css Code:
    1. QScrollBar:vertical {
    2. border: 2px solid grey;
    3. background: white;
    4. width: 15px;
    5. margin: 22px 0 22px 0;
    6. }
    7. QScrollBar::handle:vertical {
    8. border-image: url("/tmp/x/scrollbar.png") 2 0 2 0 repeat;
    9. border-top: 2px;
    10. border-bottom: 2px;
    11.  
    12. }
    To copy to clipboard, switch view to plain text mode 
    Attached Images Attached Images

  20. #20
    Join Date
    Mar 2006
    Location
    Argentina - CABA
    Posts
    66
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Platforms
    Unix/X11

    Default Re: QScrollbar stylesheet

    Quote Originally Posted by wysota View Post
    Why do you keep ignoring what I'm telling you? I asked for a single image consisting of the three images composed into one and I asked you to attach it to your post. We don't like when people use 3rd party sites to link to images, because then they tend to remove the images and we're left with dangling links and when other people have similar problems, they can't trace the thread because of missing links.

    Anyway, here is your stylesheet. I only include the part that is different from the stylesheet in the example about styling QScrollBar in the manual.

    css Code:
    1. QScrollBar:vertical {
    2. border: 2px solid grey;
    3. background: white;
    4. width: 15px;
    5. margin: 22px 0 22px 0;
    6. }
    7. QScrollBar::handle:vertical {
    8. border-image: url("/tmp/x/scrollbar.png") 2 0 2 0 repeat;
    9. border-top: 2px;
    10. border-bottom: 2px;
    11.  
    12. }
    To copy to clipboard, switch view to plain text mode 
    Ok, that worked.. i was not understanding what you mean before...
    I will try to round it a little more thanks!

    Now.. what about the Grip? any tip?
    Last edited by GuS; 2nd December 2007 at 15:33.
    Gustavo A. DÃ*az
    artistic.gdnet.com.ar

Similar Threads

  1. Stylesheet and QFontMetrics
    By ucomesdag in forum Qt Programming
    Replies: 7
    Last Post: 18th January 2010, 07:45
  2. QTreeView rows (items) StyleSheet
    By Kostanev in forum Qt Programming
    Replies: 1
    Last Post: 15th September 2007, 10:36
  3. QLabel Stylesheet selector issue.
    By Enygma in forum Qt Programming
    Replies: 3
    Last Post: 24th August 2007, 14:52
  4. QToolBar Stylesheet
    By guilugi in forum Qt Programming
    Replies: 2
    Last Post: 5th July 2007, 11:47
  5. override wheelEvent for QScrollBar
    By ChasW in forum Qt Programming
    Replies: 6
    Last Post: 25th January 2007, 09:50

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.