Created
November 1, 2018 12:32
-
-
Save MasterAler/d889153726c56899b847b8505e5b7838 to your computer and use it in GitHub Desktop.
SliderProxyStyle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include <QProxyStyle> | |
/*! | |
* \brief The SliderProxyStyle class | |
* This proxy style adds "mouse direct jump" to QSlider, i.e. | |
* QSlider with this style receives the ability to have it's value set | |
* by clicking on the desired position. | |
* Source: https://stackoverflow.com/questions/11132597/qslider-mouse-direct-jump | |
* | |
* Usage: mySlider.setStyle(new SliderProxyStyle(mySlider->style())); | |
*/ | |
class SliderProxyStyle : public QProxyStyle | |
{ | |
public: | |
using QProxyStyle::QProxyStyle; | |
int styleHint(QStyle::StyleHint hint, const QStyleOption* option = nullptr | |
, const QWidget* widget = nullptr, QStyleHintReturn* returnData = nullptr) const | |
{ | |
if (hint == QStyle::SH_Slider_AbsoluteSetButtons) | |
return (Qt::LeftButton | Qt::MidButton | Qt::RightButton); | |
return QProxyStyle::styleHint(hint, option, widget, returnData); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment