keep working on the Slider

This commit is contained in:
laserpants 2016-05-01 20:07:21 +03:00
parent c9b9061e2a
commit 4410730f22
2 changed files with 15 additions and 3 deletions

View File

@ -32,8 +32,6 @@ void Handle::paintEvent(QPaintEvent *event)
QPainter painter(this); QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing); painter.setRenderHint(QPainter::Antialiasing);
//painter.drawRect(rect());
QBrush brush; QBrush brush;
brush.setColor(QColor(0, 0, 0)); brush.setColor(QColor(0, 0, 0));
brush.setStyle(Qt::SolidPattern); brush.setStyle(Qt::SolidPattern);
@ -101,16 +99,30 @@ Slider::Slider(QWidget *parent)
_phaseAnimation->setDuration(500); _phaseAnimation->setDuration(500);
setMouseTracking(true); setMouseTracking(true);
setFocusPolicy(Qt::StrongFocus);
} }
Slider::~Slider() Slider::~Slider()
{ {
} }
void Slider::setOrientation(Qt::Orientation orientation)
{
if (_orientation == orientation)
return;
_orientation = orientation;
_handle->refreshGeometry();
update();
}
void Slider::paintEvent(QPaintEvent *event) void Slider::paintEvent(QPaintEvent *event)
{ {
QPainter painter(this); QPainter painter(this);
if (hasFocus()) {
painter.drawRect(rect());
}
QRect rect = Qt::Vertical == _orientation QRect rect = Qt::Vertical == _orientation
? QRect(width()/2-1, 0, 2, height()) ? QRect(width()/2-1, 0, 2, height())
: QRect(0, height()/2-1, width(), 2); : QRect(0, height()/2-1, width(), 2);

View File

@ -60,7 +60,7 @@ public:
explicit Slider(QWidget *parent = 0); explicit Slider(QWidget *parent = 0);
~Slider(); ~Slider();
inline void setOrientation(Qt::Orientation orientation) { _orientation = orientation; } void setOrientation(Qt::Orientation orientation);
inline Qt::Orientation orientation() const { return _orientation; } inline Qt::Orientation orientation() const { return _orientation; }
protected: protected: