Results 1 to 3 of 3

Thread: Setting a transparent background to QScrollbar using stylesheets

  1. #1
    Join Date
    Jun 2011
    Posts
    17
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Setting a transparent background to QScrollbar using stylesheets

    Hi,

    I am currently trying to set a scrollbar with completely transparent background.

    It works well for the part under the handler, which is completely transparent, but in the part where the handler is not, some kind of white canvas remains...

    See a picture in the attachment.

    Here's the stylesheet I use for Scrollbars:

    Qt Code:
    1. QScrollBar:vertical {
    2. background: transparent;
    3. width: 19px;
    4. padding: 0 0 20px 0;
    5. margin: 20px 0 20px 0;
    6. }
    7. QScrollBar::handle:vertical {
    8. background: transparent;
    9. border-image: url(scrollbar.png) 4 0 4 0 repeat;
    10. border-top: 4px;
    11. border-bottom: 4px;
    12. min-height: 39px;
    13. }
    14. QScrollBar::add-line:vertical {
    15. border-top: solid 5px transparent;
    16. background: none;
    17. height: 20px;
    18. subcontrol-position: bottom;
    19. subcontrol-origin: padding;
    20. }
    21. QScrollBar::sub-line:vertical {
    22. border: none;
    23. background: none;
    24. height: 20px;
    25. subcontrol-position: top;
    26. subcontrol-origin: margin;
    27. }
    28. QScrollBar::up-arrow:vertical{
    29. image: url(uparrow.png);
    30. }
    31. QScrollBar::down-arrow:vertical{
    32. image: url(downarrow.png);
    33. }
    To copy to clipboard, switch view to plain text mode 

    Any idea ?

    Thanks a lot.
    Márwyn
    Attached Images Attached Images

  2. #2
    Join Date
    Jun 2011
    Location
    Finland
    Posts
    164
    Thanks
    1
    Thanked 26 Times in 26 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Maemo/MeeGo

    Default Re: Setting a transparent background to QScrollbar using stylesheets

    Yes, there is some bug/feature in rendering the background for scrollbar

    In my opinion the implementation of drawing widgets with stylesheets is a little bit messy. Certain parts are drawn using stylesheets, some other using current style, some other hardcoded style. Therefore if you run your application on Linux, you don't get the problem that you get on your Windows machine.

    Try to run your app with different style that Windows default and see what happens

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

    marwyn (16th June 2011)

  4. #3
    Join Date
    Jun 2011
    Posts
    17
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Setting a transparent background to QScrollbar using stylesheets

    Thanks a lot !
    Setting the scrollbar style to another style did the trick !
    Qt Code:
    1. myScrollbar->setStyle( new QCommonStyle );
    To copy to clipboard, switch view to plain text mode 

    Still, this is (a bit) hacky... Is there no clean way to do that ?
    Anyway, it will do for now, until I find something else

    Thx again !
    Márwyn

Similar Threads

  1. Problem: Transparent Background with Stylesheets
    By dropkickz in forum Qt Programming
    Replies: 2
    Last Post: 7th June 2011, 10:58
  2. Qt Widgets seen half transparent when using stylesheets
    By codeslicer in forum Qt Programming
    Replies: 5
    Last Post: 14th December 2010, 09:52
  3. Transparent QScrollbar groove in QWebView
    By Jonas in forum Qt Programming
    Replies: 0
    Last Post: 20th October 2008, 08:55
  4. QScrollbar Stylesheets problems in Qt4.4
    By GuS in forum Qt Programming
    Replies: 2
    Last Post: 6th September 2008, 20:37
  5. Transparent background on QLabel on transparent QWidget
    By codeslicer in forum Qt Programming
    Replies: 1
    Last Post: 13th February 2008, 02:10

Tags for this Thread

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.