Results 1 to 5 of 5

Thread: QScrollbar handle stretch problem

  1. #1
    Join Date
    Apr 2009
    Posts
    18
    Thanks
    3
    Thanked 2 Times in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default QScrollbar handle stretch problem

    Hi all,

    I'm styling my scrollbar and I have a problem on stretching the scrollbar's handle.

    I read this post

    http://www.qtcentre.org/forum/f-qt-p...eet-10569.html

    and I understand that styling the handle means stretch an image like this:

    "The middle parts will be stretched or repeated (depending on your settings) and corners will be applied without any scaling to prevent distortions."

    I would like not to stretch the middle part and to strecth, instead, the corners.

    Is it possible using QStyleSheet? I have to define my custom style?

    Thank you for any suggestion.

    Beppe

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

    Default Re: QScrollbar handle stretch problem

    I don't think you can do that using stylesheets... I can't think of any possible reason to want to stretch corners, anyway... I'd suggest you implemented your own widget style for the scroll bar and apply it using the proxy style technique.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Apr 2009
    Posts
    18
    Thanks
    3
    Thanked 2 Times in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: QScrollbar handle stretch problem

    Thank you wysota,

    if you say
    I can't think of any possible reason to want to stretch corners, anyway...
    maybe I don't cope with the problem in the correct way.

    I have an image (handle.jpg) applied to the handle of the scrollbar. With StyleSheet I set the handle's minimum size and it works correctly.

    When the scrollbar grows, the handle image is stretched but the final effect is awful (see the second image).

    my stylesheet code is


    Qt Code:
    1. QScrollBar::vertical {\
    2. background:lightgray;\
    3. border-color:black;\
    4. border-style:solid;\
    5. width: 50px;\
    6. margin-top:1px;\
    7. margin-bottom:1px;\
    8. }\
    9. \
    10. QScrollBar::handle:vertical,\
    11. QScrollBar::handle:pressed{\
    12. border-image: url(handle.png);\
    13. min-height: 96px; \
    14. } \
    15. \
    16. QScrollBar::add-line:vertical{\
    17. background:none;\
    18. border-width:0px;\
    19. height: 0px;\
    20. width: 0px; \
    21. } \
    22. \
    23. QScrollBar::sub-line:vertical { \
    24. background:none;\
    25. border-width:0px;\
    26. height: 0px;\
    27. width: 0px; \
    28. } \
    29. \
    30. QScrollBar::add-page:vertical, \
    31. QScrollBar::sub-page:vertical {\
    32. background: none;\
    33. }\
    34. \
    35. QScrollBar::add-line:pressed,\
    36. QScrollBar::sub-line:pressed {\
    37. background: none;\
    38. }
    To copy to clipboard, switch view to plain text mode 

    Thanks

    Beppe
    Attached Images Attached Images

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

    Default Re: QScrollbar handle stretch problem

    But stretching corners will not help you in any way.

    You should create your own style. Unfortunately QScrollBar doesn't have any special sub-control for the middle part of the handle.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Apr 2009
    Posts
    18
    Thanks
    3
    Thanked 2 Times in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: QScrollbar handle stretch problem

    OK. Thanks

Similar Threads

  1. problem in installing qt4.4.3 source
    By wagmare in forum Qt-based Software
    Replies: 0
    Last Post: 18th February 2009, 06:48
  2. Weird problem: multithread QT app kills my linux
    By Ishark in forum Qt Programming
    Replies: 2
    Last Post: 8th August 2008, 09:12

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.