[UNSOLVED]QScrollBar with big handle



  • Hi,

    How can I modify the handle size of QScrollBar using stylesheets?

    I tried the following but it didn't affect on width of the handler (I want it very big because I'm using Qt widget under Android)

    [code] QScrollBar:vertical {
    border: 2px solid grey;
    background: #32CC99;
    width: 15px;
    margin: 22px 0 22px 0;
    }
    QScrollBar::handle:vertical {
    background: white;
    min-height: 20px;
    }

    /**** I WANT A BIG HANDLE HERE!!! ****/
    QScrollBar::handle:vertical:hover {
    background: red;
    min-width:100px;
    }

    QScrollBar::add-line:vertical {
    border: 2px solid grey;
    background: blue;
    height: 20px;
    subcontrol-position: bottom;
    subcontrol-origin: margin;
    }

    QScrollBar::sub-line:vertical {
    border: 2px solid grey;
    background: #32CC99;
    height: 20px;
    subcontrol-position: top;
    subcontrol-origin: margin;
    }
    QScrollBar::up-arrow:vertical, QScrollBar::down-arrow:vertical {
    border: 2px solid grey;
    width: 3px;
    height: 3px;
    background: white;
    }

    QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {
    background: none;
    }[/code]



  • Bump it :)

    Do you've any suggestion guys?



  • Hi mbnoimi,

    you can try for like this

    /**** I WANT A BIG HANDLE HERE!!! ****/
    QScrollBar::handle:vertical:hover {
    background: red;
    min-width:100px;
    margin: 0 100px 0 100px;
    }

    or in other way you inherit the QScrollbar class into custom class and reimplment the paint event and modify as you want....

    As far as i know handle size is bound to its parent size i.e. QScrollbar size if we keep QScrollbar size like 20 in width then max width size for handler is 20 unless & unitl we are not reimplement it and modify as we want apart from style sheet.

    Thanks
    Prashant Moglaikar



  • [quote author="Prashant Moglaikar" date="1399353126"]Hi mbnoimi,

    you can try for like this

    /**** I WANT A BIG HANDLE HERE!!! ****/
    QScrollBar::handle:vertical:hover {
    background: red;
    min-width:100px;
    margin: 0 100px 0 100px;
    }

    [/quote]

    This doens't work because it strict with QScrollbar width!

    bq. or in other way you inherit the QScrollbar class into custom class and reimplment the paint event and modify as you want....

    You mean there no way to modify it wihotut class custmozation?!

    I didn't expect this complication.



  • Did you try QApplication::setGlobalStrut? It controls the minimum size of elements that you interact with.



  • [quote author="Andre" date="1399392407"]Did you try QApplication::setGlobalStrut? It controls the minimum size of elements that you interact with.[/quote]

    How this will help me if I want to view the big size of scroll handle only and just only on hover event?

    In simple words; I want to increase handle's size only when I put my finger over it, otherwise the scroll should be a small.



  • BTW; I tested this solution before as mentions "in this post":http://doc.qt.digia.com/qq/qq09-q-and-a.html#scrolls



  • [quote author="mbnoimi" date="1399533204"][quote author="Andre" date="1399392407"]Did you try QApplication::setGlobalStrut? It controls the minimum size of elements that you interact with.[/quote]

    How this will help me if I want to view the big size of scroll handle only and just only on hover event?

    In simple words; I want to increase handle's size only when I put my finger over it, otherwise the scroll should be a small.[/quote]
    It won't, but that requirement was not clear to me from your previous posts.

    I suggest you look at using QML instead. It is way easier to make dynamic UI's like you seem to be after than using widgets.



  • [quote author="Andre" date="1399536323"]
    It won't, but that requirement was not clear to me from your previous posts. [/quote]
    You mean there is no easy way to do it in QtWidgets?
    [quote author="Andre" date="1399536323"]
    I suggest you look at using QML instead. It is way easier to make dynamic UI's like you seem to be after than using widgets.
    [/quote]
    I made a discussion about QtQuick before as mentioned "in this post":http://qt-project.org/forums/viewthread/32085/ and I couldn't move to QML because if hasn't open source designer similar to Qt Designer and I don't want to design the GUI from the source code.

    BTW; The only thing forced me to use Qt is the GUI Designer without it I'll definitely migrate to Web Frameworks (I made some successful tiny projects using "Wt":http://www.webtoolkit.eu/wt); So it's vital matter for me to design my apps graphically.



  • It does in my version of Creator... And yes, I do mean that changing widget sizes on hover, especially in a nice, animated way, is very very hard to realize with QWidgets. OTOH, also realize that there really isn't a hover event on touch screen systems. At least, not on the ones I know off, although I do know about research devices that also detect a finger hovering over a screen.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.