Let’s check the result first
/***************** head file *****************/
#ifndef SLIDER_H
#define SLIDER_H
#include <QWidget>
#include <QDebug>
#include <QPainter>
class Slider : public QWidget
{
Q_OBJECT
public:
Slider(QWidget* parent = nullptr);
void setValue(int value);
void setMax(int max);
void paintEvent(QPaintEvent *ev) ;
void setButtonWidth(int w);
void setRightGap(int gap);
protected:
void mousePressEvent(QMouseEvent *event) ;
void mouseMoveEvent(QMouseEvent *event) ;
void mouseReleaseEvent(QMouseEvent *event);
private:
double knobPos;
int maximum;