Qwt User's Guide  6.2.0
qwt_slider.h
1 /******************************************************************************
2  * Qwt Widget Library
3  * Copyright (C) 1997 Josef Wilgen
4  * Copyright (C) 2002 Uwe Rathmann
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the Qwt License, Version 1.0
8  *****************************************************************************/
9 
10 #ifndef QWT_SLIDER_H
11 #define QWT_SLIDER_H
12 
13 #include "qwt_global.h"
14 #include "qwt_abstract_slider.h"
15 
16 class QwtScaleDraw;
17 
30 class QWT_EXPORT QwtSlider : public QwtAbstractSlider
31 {
32  Q_OBJECT
33 
34  Q_ENUMS( ScalePosition BackgroundStyle )
35 
36  Q_PROPERTY( Qt::Orientation orientation
37  READ orientation WRITE setOrientation )
38  Q_PROPERTY( ScalePosition scalePosition READ scalePosition
39  WRITE setScalePosition )
40 
41  Q_PROPERTY( bool trough READ hasTrough WRITE setTrough )
42  Q_PROPERTY( bool groove READ hasGroove WRITE setGroove )
43 
44  Q_PROPERTY( QSize handleSize READ handleSize WRITE setHandleSize )
45  Q_PROPERTY( int borderWidth READ borderWidth WRITE setBorderWidth )
46  Q_PROPERTY( int spacing READ spacing WRITE setSpacing )
47 
48  public:
49 
55  {
58 
61 
63  TrailingScale
64  };
65 
66  explicit QwtSlider( QWidget* parent = NULL );
67  explicit QwtSlider( Qt::Orientation, QWidget* parent = NULL );
68 
69  virtual ~QwtSlider();
70 
71  void setOrientation( Qt::Orientation );
72  Qt::Orientation orientation() const;
73 
74  void setScalePosition( ScalePosition );
75  ScalePosition scalePosition() const;
76 
77  void setTrough( bool );
78  bool hasTrough() const;
79 
80  void setGroove( bool );
81  bool hasGroove() const;
82 
83  void setHandleSize( const QSize& );
84  QSize handleSize() const;
85 
86  void setBorderWidth( int );
87  int borderWidth() const;
88 
89  void setSpacing( int );
90  int spacing() const;
91 
92  virtual QSize sizeHint() const QWT_OVERRIDE;
93  virtual QSize minimumSizeHint() const QWT_OVERRIDE;
94 
95  void setScaleDraw( QwtScaleDraw* );
96  const QwtScaleDraw* scaleDraw() const;
97 
98  void setUpdateInterval( int );
99  int updateInterval() const;
100 
101  protected:
102  virtual double scrolledTo( const QPoint& ) const QWT_OVERRIDE;
103  virtual bool isScrollPosition( const QPoint& ) const QWT_OVERRIDE;
104 
105  virtual void drawSlider ( QPainter*, const QRect& ) const;
106  virtual void drawHandle( QPainter*, const QRect&, int pos ) const;
107 
108  virtual void mousePressEvent( QMouseEvent* ) QWT_OVERRIDE;
109  virtual void mouseReleaseEvent( QMouseEvent* ) QWT_OVERRIDE;
110  virtual void resizeEvent( QResizeEvent* ) QWT_OVERRIDE;
111  virtual void paintEvent ( QPaintEvent* ) QWT_OVERRIDE;
112  virtual void changeEvent( QEvent* ) QWT_OVERRIDE;
113  virtual void timerEvent( QTimerEvent* ) QWT_OVERRIDE;
114 
115  virtual bool event( QEvent* ) QWT_OVERRIDE;
116 
117  virtual void scaleChange() QWT_OVERRIDE;
118 
119  QRect sliderRect() const;
120  QRect handleRect() const;
121 
122  private:
123  QwtScaleDraw* scaleDraw();
124 
125  void layoutSlider( bool );
126  void initSlider( Qt::Orientation );
127 
128  class PrivateData;
129  PrivateData* m_data;
130 };
131 
132 #endif
An abstract base class for slider widgets with a scale.
A class for drawing scales.
The Slider Widget.
Definition: qwt_slider.h:31
@ LeadingScale
The scale is right of a vertical or below a horizontal slider.
Definition: qwt_slider.h:60
@ NoScale
The slider has no scale.
Definition: qwt_slider.h:57