QSlider direct jump on click By default, QSlider move his thumbtrack by a value belonging to the singleStep() prop on mouse click. To make thumbtrack jump directly at the mouse click point, we need to create a new class inherited by QSlider.

Header file (.h):

#include &lt;QWidget&gt;
#include &lt;QAbstractSlider&gt;
#include &lt;QSlider&gt;
#include &lt;QMouseEvent&gt;
#include &lt;QStyle&gt;
#include &lt;QStyleOptionSlider&gt;
#ifndef QIMPROVEDSLIDER_H
#define QIMPROVEDSLIDER_H

class QImprovedSlider : public QSlider
{
    Q_OBJECT
protected:
    void mousePressEvent(QMouseEvent *event);

public:
    explicit QImprovedSlider(QWidget *parent = 0);

    ~QImprovedSlider();

public slots:

private:

private slots:

signals:
    void onClick(int value);
};

#endif // QIMPROVEDSLIDER_H


Source file (.cpp):

#include "QImprovedSlider.h"


QImprovedSlider::QImprovedSlider(QWidget *parent) :
    QSlider(parent)
{

}

QImprovedSlider::~QImprovedSlider()
{
}

void QImprovedSlider::mousePressEvent(QMouseEvent *event) {
  QStyleOptionSlider opt;
  initStyleOption(&amp;opt);
  QRect sr = style()-&gt;subControlRect(QStyle::CC_Slider, &amp;opt, QStyle::SC_SliderHandle, this);

  if (event-&gt;button() == Qt::LeftButton &amp;&amp;
      !sr.contains(event-&gt;pos())) {
    int newVal;
    if (orientation() == Qt::Vertical) {
       double halfHandleHeight = (0.5 * sr.height()) + 0.5;
       int adaptedPosY = height() - event-&gt;y();
       if ( adaptedPosY &lt; halfHandleHeight )
             adaptedPosY = halfHandleHeight;
       if ( adaptedPosY &gt; height() - halfHandleHeight )
             adaptedPosY = height() - halfHandleHeight;
       double newHeight = (height() - halfHandleHeight) - halfHandleHeight;
       double normalizedPosition = (adaptedPosY - halfHandleHeight)  / newHeight ;

       newVal = minimum() + (maximum()-minimum()) * normalizedPosition;
    } else {
        double halfHandleWidth = (0.5 * sr.width()) + 0.5;
        int adaptedPosX = event-&gt;x();
        if ( adaptedPosX &lt; halfHandleWidth )
              adaptedPosX = halfHandleWidth;
        if ( adaptedPosX &gt; width() - halfHandleWidth )
              adaptedPosX = width() - halfHandleWidth;
        double newWidth = (width() - halfHandleWidth) - halfHandleWidth;
        double normalizedPosition = (adaptedPosX - halfHandleWidth)  / newWidth ;

        newVal = minimum() + ((maximum()-minimum()) * normalizedPosition);
    }

    if (invertedAppearance())
        this-&gt;setValue( maximum() - newVal );
    else
        this-&gt;setValue(newVal);

    event-&gt;accept();
  }
  else {
        QSlider::mousePressEvent(event);
  }
  emit onClick(this-&gt;value());
}


This code works well, so is not a broken code. There is a way to improve this? Maybe trying to differentiate the direct jump from the handle dragging
if (invertedAppearance()) {
        this-&gt;setValue( maximum() - newVal ); 
} else {
        this-&gt;setValue(newVal);
}


You should not be posting if/else statements without Curly Braces. The style leaves you open for massive bugs, and as an after thought: makes it cumbersome for you or other developers to add to this code.

So for example, let's say you are editing or debugging your code, and decide to comment out a line:

if (invertedAppearance())
    this-&gt;setValue( maximum() - newVal );
else
    // this-&gt;setValue(newVal); 

event-&gt;accept();


Do you see the issue?