Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QSlider + QSS + Ticks
Forum Updated to NodeBB v4.3 + New Features

QSlider + QSS + Ticks

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 6.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    RiseOfDeath
    wrote on last edited by
    #1

    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!)

    1 Reply Last reply
    0
    • N Offline
      N Offline
      NicuPopescu
      wrote on last edited by
      #2

      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!

      1 Reply Last reply
      0
      • R Offline
        R Offline
        RiseOfDeath
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • N Offline
          N Offline
          NicuPopescu
          wrote on last edited by
          #4

          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

          :)

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved