QWT API (中文) 7.3.0
Qt绘图库 - 中文API文档
载入中...
搜索中...
未找到
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 * Modified by ChenZongYan in 2024 <czy.t@163.com>
10 * Summary of major modifications (see ChangeLog.md for full history):
11 * 1. CMake build system & C++11 throughout.
12 * 2. Core panner/ zoomer refactored:
13 * - QwtPanner → QwtCachePanner (pixmap-cache version)
14 * - New real-time QwtPlotPanner derived from QwtPicker.
15 * 3. Zoomer supports multi-axis.
16 * 4. Parasite-plot framework:
17 * - QwtFigure, QwtPlotParasiteLayout, QwtPlotTransparentCanvas,
18 * - QwtPlotScaleEventDispatcher, built-in pan/zoom on axis.
19 * 5. New picker: QwtPlotSeriesDataPicker (works with date axis).
20 * 6. Raster & color-map extensions:
21 * - QwtGridRasterData (2-D table + interpolation)
22 * - QwtLinearColorMap::stopColors(), stopPos() API rename.
23 * 7. Bar-chart: expose pen/brush control.
24 * 8. Amalgamated build: single QwtPlot.h / QwtPlot.cpp pair in src-amalgamate.
25 *****************************************************************************/
26
27#ifndef QWT_SLIDER_H
28#define QWT_SLIDER_H
29
30#include "qwt_global.h"
31#include "qwt_abstract_slider.h"
32
33class QwtScaleDraw;
34
44class QWT_EXPORT QwtSlider : public QwtAbstractSlider
45{
46 Q_OBJECT
47
48 Q_ENUMS(ScalePosition)
49
50 Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation)
51 Q_PROPERTY(ScalePosition scalePosition READ scalePosition WRITE setScalePosition)
52
53 Q_PROPERTY(bool trough READ hasTrough WRITE setTrough)
54 Q_PROPERTY(bool groove READ hasGroove WRITE setGroove)
55
56 Q_PROPERTY(QSize handleSize READ handleSize WRITE setHandleSize)
57 Q_PROPERTY(int borderWidth READ borderWidth WRITE setBorderWidth)
58 Q_PROPERTY(int spacing READ spacing WRITE setSpacing)
59 Q_PROPERTY(bool flatStyle READ flatStyle WRITE setFlatStyle)
60
61public:
67 {
70
73
75 TrailingScale
76 };
77
79 explicit QwtSlider(QWidget* parent = nullptr);
81 explicit QwtSlider(Qt::Orientation, QWidget* parent = nullptr);
82
84 ~QwtSlider() override;
85
87 void setOrientation(Qt::Orientation);
89 Qt::Orientation orientation() const;
90
92 void setScalePosition(ScalePosition);
94 ScalePosition scalePosition() const;
95
97 void setTrough(bool);
99 bool hasTrough() const;
100
102 void setGroove(bool);
104 bool hasGroove() const;
105
107 void setHandleSize(const QSize&);
109 QSize handleSize() const;
110
112 void setBorderWidth(int);
114 int borderWidth() const;
115
117 void setSpacing(int);
119 int spacing() const;
120
122 void setFlatStyle(bool);
124 bool flatStyle() const;
125
127 virtual QSize sizeHint() const override;
129 virtual QSize minimumSizeHint() const override;
130
132 void setScaleDraw(QwtScaleDraw*);
134 const QwtScaleDraw* scaleDraw() const;
135
137 void setUpdateInterval(int);
139 int updateInterval() const;
140
141protected:
143 virtual double scrolledTo(const QPoint&) const override;
145 virtual bool isScrollPosition(const QPoint&) const override;
146
148 virtual void drawSlider(QPainter*, const QRect&) const;
150 virtual void drawHandle(QPainter*, const QRect&, int pos) const;
151
153 virtual void mousePressEvent(QMouseEvent*) override;
155 virtual void mouseReleaseEvent(QMouseEvent*) override;
157 virtual void resizeEvent(QResizeEvent*) override;
159 virtual void paintEvent(QPaintEvent*) override;
161 virtual void changeEvent(QEvent*) override;
163 virtual void timerEvent(QTimerEvent*) override;
164
166 virtual bool event(QEvent*) override;
167
169 virtual void scaleChange() override;
170
172 QRect sliderRect() const;
174 QRect handleRect() const;
175
176private:
178 QwtScaleDraw* scaleDraw();
179
181 void layoutSlider(bool);
183 void initSlider(Qt::Orientation);
184
185 QWT_DECLARE_PRIVATE(QwtSlider)
186};
187
188#endif
virtual void changeEvent(QEvent *) override
Handle change events (English only)
Definition qwt_abstract_scale.cpp:454
An abstract base class for slider widgets with a scale
Definition qwt_abstract_slider.h:47
virtual void scaleChange() override
Handle scale changes (English only)
Definition qwt_abstract_slider.cpp:776
virtual void mouseReleaseEvent(QMouseEvent *) override
Handle mouse release events (English only)
Definition qwt_abstract_slider.cpp:273
virtual void mousePressEvent(QMouseEvent *) override
Handle mouse press events (English only)
Definition qwt_abstract_slider.cpp:206
A class for drawing scales
Definition qwt_scale_draw.h:52
The Slider Widget
Definition qwt_slider.h:45
ScalePosition
Position of the scale
Definition qwt_slider.h:67
@ LeadingScale
The scale is right of a vertical or below a horizontal slider
Definition qwt_slider.h:72
@ NoScale
The slider has no scale
Definition qwt_slider.h:69