-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
damc_gui: set sliders to 0 on double click
- Loading branch information
Showing
3 changed files
with
52 additions
and
15 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// From https://stackoverflow.com/questions/52550633/how-to-emit-a-signal-if-double-clicking-on-slider-handle | ||
|
||
#include "DoubleClickSlider.h" | ||
#include <QStyleOption> | ||
|
||
DoubleClickSlider::DoubleClickSlider(QWidget* parent) : QSlider(parent) {} | ||
|
||
void DoubleClickSlider::mouseDoubleClickEvent(QMouseEvent* event) { | ||
QStyleOptionSlider opt; | ||
this->initStyleOption(&opt); | ||
QRect sr = this->style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderHandle, this); | ||
|
||
if(sr.contains(event->pos())) { | ||
printf("Set slider to 0\n"); | ||
setValue(0); | ||
} else { | ||
QSlider::mouseDoubleClickEvent(event); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#pragma once | ||
|
||
#include <QMouseEvent> | ||
#include <QSlider> | ||
|
||
class DoubleClickSlider : public QSlider { | ||
Q_OBJECT | ||
public: | ||
DoubleClickSlider(QWidget* parent = nullptr); | ||
|
||
protected: | ||
void mouseDoubleClickEvent(QMouseEvent* event) override; | ||
}; |
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