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 Handle Size
Qt 6.11 is out! See what's new in the release blog

QSlider Handle Size

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 925 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.
  • webzoidW Offline
    webzoidW Offline
    webzoid
    wrote on last edited by
    #1

    Is there any way to obtain the physical geometry of the handle belonging to a QSlider?

    I'm wanting to get the pixel location of the centre point of the handle so I can then draw text above it.

    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by VRonin
      #2
      QStyleOptionSlider opt;
      initStyleOption(&opt);
      opt.subControls = QStyle::SC_SliderGroove | QStyle::SC_SliderHandle;
      QRect handleRect =style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderHandle, this);
      

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

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

        @VRonin Thanks for your response.

        This seems pretty good. One question though, which header file contains the initStyleOption declaration?

        webzoidW 1 Reply Last reply
        0
        • webzoidW webzoid

          @VRonin Thanks for your response.

          This seems pretty good. One question though, which header file contains the initStyleOption declaration?

          webzoidW Offline
          webzoidW Offline
          webzoid
          wrote on last edited by
          #4

          Please ignore my last comment. I wasn't subclassing the QSlider when I made that comment.

          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