SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
Public Member Functions | Protected Member Functions | Private Attributes | List of all members
TickedSlider Class Reference

#include <tickedslider.h>

Inherits QSlider.

Public Member Functions

 TickedSlider (QWidget *parent=0)
 
void setTickColor (const QColor &color)
 

Protected Member Functions

virtual void paintEvent (QPaintEvent *ev)
 

Private Attributes

QColor m_tickColor
 

Detailed Description

Definition at line 28 of file tickedslider.h.

Constructor & Destructor Documentation

◆ TickedSlider()

TickedSlider::TickedSlider ( QWidget *  parent = 0)

Definition at line 27 of file tickedslider.cpp.

27  :
28  QSlider(parent),
29  m_tickColor(Qt::white)
30 { }
QColor m_tickColor
Definition: tickedslider.h:38

Member Function Documentation

◆ paintEvent()

void TickedSlider::paintEvent ( QPaintEvent *  ev)
protectedvirtual

Definition at line 32 of file tickedslider.cpp.

References i, and m_tickColor.

33 {
34  (void) ev;
35  QStylePainter p(this);
36  QStyleOptionSlider opt;
37  initStyleOption(&opt);
38 
39  QRect handle = style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderHandle, this);
40 
41  // draw tick marks
42  // do this manually because they are very badly behaved with style sheets
43  int interval = tickInterval();
44  if (interval == 0)
45  {
46  interval = pageStep();
47  }
48 
49  if (tickPosition() != NoTicks)
50  {
51  for (int i = minimum(); i <= maximum(); i += interval)
52  {
53  int x = roundf((double)((double)((double)(i - this->minimum()) / (double)(this->maximum() - this->minimum())) * (double)(this->width() - handle.width()) + (double)(handle.width() / 2.0))) - 1;
54  int h = 4;
55  p.setPen(m_tickColor);
56  if (tickPosition() == TicksBothSides || tickPosition() == TicksAbove)
57  {
58  int y = this->rect().top();
59  p.drawLine(x, y, x, y + h);
60  }
61  if (tickPosition() == TicksBothSides || tickPosition() == TicksBelow)
62  {
63  int y = this->rect().bottom();
64  p.drawLine(x, y, x, y - h);
65  }
66 
67  }
68  }
69 
70  // draw the slider (this is basically copy/pasted from QSlider::paintEvent)
71  opt.subControls = QStyle::SC_SliderGroove;
72  p.drawComplexControl(QStyle::CC_Slider, opt);
73 
74  // draw the slider handle
75  opt.subControls = QStyle::SC_SliderHandle;
76  p.drawComplexControl(QStyle::CC_Slider, opt);
77 }
QColor m_tickColor
Definition: tickedslider.h:38
int32_t i
Definition: decimators.h:244

◆ setTickColor()

void TickedSlider::setTickColor ( const QColor &  color)
inline

Definition at line 32 of file tickedslider.h.

32 { m_tickColor = color; }
QColor m_tickColor
Definition: tickedslider.h:38

Member Data Documentation

◆ m_tickColor

QColor TickedSlider::m_tickColor
private

Definition at line 38 of file tickedslider.h.

Referenced by paintEvent().


The documentation for this class was generated from the following files: