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. How to set QSlider::handle to round ?

How to set QSlider::handle to round ?

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 9.1k Views
  • 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.
  • sonichyS Offline
    sonichyS Offline
    sonichy
    wrote on last edited by
    #1

    Why my handle is an ellipse, I want a circle handle.

    setStyleSheet("QSlider::sub-page:Horizontal { background-color: #9F2425; }"
                  "QSlider::add-page:Horizontal { background-color: #333333; }"
                  "QSlider::groove:Horizontal { background: transparent; height:4px; }"
                  "QSlider::handle:Horizontal { width:10px; border-radius:5px; background:#9F2425; margin: -5px 0px -5px 0px; }");
    

    替代文字

    https://github.com/sonichy

    1 Reply Last reply
    0
    • webzoidW Offline
      webzoidW Offline
      webzoid
      wrote on last edited by
      #2

      @sonichy This is how I achieved a circular handle:

      QSlider::groove:horizontal { 
      	background-color: black;
      	border: 0px solid #424242; 
      	height: 10px; 
      	border-radius: 4px;
      }
      
      QSlider::handle:horizontal { 
      	background-color: red; 
      	border: 2px solid red; 
      	width: 16px; 
      	height: 20px; 
      	line-height: 20px; 
      	margin-top: -5px; 
      	margin-bottom: -5px; 
      	border-radius: 10px; 
      }
      
      QSlider::handle:horizontal:hover { 
      	border-radius: 10px;
      }
      

      The handle is a little larger than what you want but tweak the parameters where necessary.

      1 Reply Last reply
      3
      • Vinod KuntojiV Offline
        Vinod KuntojiV Offline
        Vinod Kuntoji
        wrote on last edited by
        #3

        @sonichy,

        Just adjust width and radius of slider handle
        width 11px; radius:5px;

        C++, Qt, Qt Quick Developer,
        PthinkS, Bangalore

        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