Qt World Summit: Register Today!

QSlider Handle Size

  • 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.

  • QStyleOptionSlider opt;
    opt.subControls = QStyle::SC_SliderGroove | QStyle::SC_SliderHandle;
    QRect handleRect =style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderHandle, this);

  • @VRonin Thanks for your response.

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

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

Log in to reply