Stylesheet for scrollbar in QScrollArea



  • Hello, how can i set qss style for scrollbar in QScrollArea.

    What i have tried..
    In qss for QScrollArea i set code from documentation:

    QScrollBar:vertical {
        border: 2px solid grey;
        background: #32CC99;
        height: 15px;
        margin: 0px 20px 0 20px;
    }
    QScrollBar::handle:vertical {
        background: white;
        min-width: 20px;
    }
    QScrollBar::add-line:vertical {
        border: 2px solid grey;
        background: #32CC99;
        width: 20px;
        subcontrol-position: right;
        subcontrol-origin: margin;
    }
    
    QScrollBar::sub-line:vertical {
        border: 2px solid grey;
        background: #32CC99;
        width: 20px;
        subcontrol-position: left;
        subcontrol-origin: margin;
    }
    

    But nothing.. scrollbar in QScrollArea still have standard style.


  • Lifetime Qt Champion

    Hi,

    How are you setting that style sheet ?
    How are you creating your QScrollArea ?

    What version of Qt are you using ?
    On what platform ?



  • Below is my working code cor Vertical Scroll Bar

    QScrollBar:vertical {border-color: #424242;border-width: 1px;border-style: solid;
        background-color: #32CC99;width: 25px;margin: 21px 0 21px 0;
        QScrollBar::handle:vertical {background-color:white ;min-height: 25px;}
        QScrollBar::add-line:vertical {border: 2px solid black;background-color: #32CC99;
        height: 25px;subcontrol-position: bottom;subcontrol-origin: margin;}
        QScrollBar::sub-line:vertical {border: 2px solid black;background-color: #32CC99;
        height: 25px;subcontrol-position: top;subcontrol-origin: margin;}
    

    the code you are using is for Horizontal scroll bar i think so, as for vertical scroll bar margin should be

    margin: 20px 0px 20px 0px;
    

    Hope this helps .


Log in to reply
 

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