QSlider + QSS + Ticks



  • Is real to make QSlider with custom style and with Ticks?

    I use this QSS style:

    @QSlider::groove:vertical {

    background: qlineargradient(x1:0, y1:0, x2:0, y2:0.7, stop:0 red, stop:1 green);

     position: absolute; 
     left: 4px; right: 4px;
     width:50px;
    

    }

    QSlider::handle:vertical {
    height:20px;
    width:50px;

    margin: 0 -4px; 
    

    background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 #b4b4b4, stop:1 #8f8f8f);
    border: 1px solid #5c5c5c;
    border-radius: 3px;
    }

    QSlider::add-page:vertical {
    background: transparent;
    }

    QSlider::sub-page:vertical {
    background: rgb(242, 241, 240);

    }@

    And in Designer set tickPosition as "TicksBothSides", but it don't work. (when i remove stylesheet all work rigth).

    Is anyone know, how to make it in Qt 4.8 ? (Not Qt 5!)



  • Hi,

    try something like:

    @#verticalSlider{
    qproperty-geometry:rect(110 60 40 700);
    border:0px solid rgba(0,0,0,0);
    border-radius: 10px;
    background:rgba(121,124,117,255);
    }

    #verticalSlider::groove:vertical {
    }

    #verticalSlider::handle:vertical {
    height:60px;
    background: red;
    border-radius: 4px;
    }

    #verticalSlider::add-page:vertical {
    background: rgba(0,0,255,255);
    margin-left:4;
    margin-right:4;
    }

    QSlider::sub-page:vertical {
    background: pink;
    margin-left:4;
    margin-right:4;
    }@

    with the drawback that handle's height and tick marks color cannot be changed: at least the the tick marks are visible with default color ... anyway, the groove painting/resizing has some strange effect over the other elements ... as you could see I don't touch it

    hope it helps a little! :)

    Cheers!



  • Thx for you answer.

    I try your stylesheet. Background loock good, but it work only if a use default handle style. when i try change it i lose ticks.



  • bq. with the drawback that handle’s height and tick marks color cannot be changed: at least the the tick marks are visible with default color

    :)


Log in to reply
 

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