QWT API (中文) 7.3.0
Qt绘图库 - 中文API文档
载入中...
搜索中...
未找到
| Public 类型 | Public 成员函数 | Protected 成员函数 | 属性 | 所有成员列表
QwtKnob类 参考

The Knob Widget 更多...

#include <qwt_knob.h>

类 QwtKnob 继承关系图:
QwtAbstractSlider QwtAbstractScale

class  PrivateData
 

Public 类型

enum  KnobStyle { Flat , Raised , Sunken , Styled }
 Style of the knob surface 更多...
 
enum  MarkerStyle {
  NoMarker = -1 , Tick , Triangle , Dot ,
  Nub , Notch
}
 Marker type 更多...
 

Public 成员函数

 QwtKnob (QWidget *parent=nullptr)
 Constructor
 
 ~QwtKnob () override
 Destructor
 
void setAlignment (Qt::Alignment)
 Set alignment of the knob inside contentsRect()
 
Qt::Alignment alignment () const
 Return alignment of the knob
 
void setKnobWidth (int)
 Set the knob's width (diameter)
 
int knobWidth () const
 Return the knob's width
 
void setNumTurns (int)
 Set the number of turns for the knob
 
int numTurns () const
 Return the number of turns
 
void setTotalAngle (double angle)
 Set the total angle which the knob can be turned
 
double totalAngle () const
 Return the total angle
 
void setKnobStyle (KnobStyle)
 Set the knob style
 
KnobStyle knobStyle () const
 Return the knob style
 
void setBorderWidth (int)
 Set the border width
 
int borderWidth () const
 Return the border width
 
void setMarkerStyle (MarkerStyle)
 Set the marker style
 
MarkerStyle markerStyle () const
 Return the marker style
 
void setMarkerSize (int)
 Set the marker size
 
int markerSize () const
 Return the marker size
 
virtual QSize sizeHint () const override
 Return size hint
 
virtual QSize minimumSizeHint () const override
 Return minimum size hint
 
void setScaleDraw (QwtRoundScaleDraw *)
 Set the scale draw
 
const QwtRoundScaleDrawscaleDraw () const
 Return the scale draw (const version)
 
QwtRoundScaleDrawscaleDraw ()
 Return the scale draw (non-const version)
 
QRect knobRect () const
 Return the bounding rectangle of the knob
 
- Public 成员函数 继承自 QwtAbstractSlider
 QwtAbstractSlider (QWidget *parent=nullptr)
 Constructor for QwtAbstractSlider (English only)
 
 ~QwtAbstractSlider () override
 Destructor for QwtAbstractSlider (English only)
 
void setValid (bool)
 Set whether the slider is valid (English only)
 
bool isValid () const
 Return whether the slider is valid (English only)
 
double value () const
 Return the current value (English only)
 
void setWrapping (bool)
 Set whether wrapping is enabled (English only)
 
bool wrapping () const
 Return whether wrapping is enabled (English only)
 
void setTotalSteps (uint)
 Set the total number of steps (English only)
 
uint totalSteps () const
 Return the total number of steps (English only)
 
void setSingleSteps (uint)
 Set the number of single steps (English only)
 
uint singleSteps () const
 Return the number of single steps (English only)
 
void setPageSteps (uint)
 Set the number of page steps (English only)
 
uint pageSteps () const
 Return the number of page steps (English only)
 
void setStepAlignment (bool)
 Set whether step alignment is enabled (English only)
 
bool stepAlignment () const
 Return whether step alignment is enabled (English only)
 
void setTracking (bool)
 Set whether tracking is enabled (English only)
 
bool isTracking () const
 Return whether tracking is enabled (English only)
 
void setReadOnly (bool)
 Set whether the slider is read-only (English only)
 
bool isReadOnly () const
 Return whether the slider is read-only (English only)
 
void setInvertedControls (bool)
 Set whether controls are inverted (English only)
 
bool invertedControls () const
 Return whether controls are inverted (English only)
 
- Public 成员函数 继承自 QwtAbstractScale
 QwtAbstractScale (QWidget *parent=nullptr)
 Constructor for QwtAbstractScale
 
void setScale (double lowerBound, double upperBound)
 Specify a scale by interval bounds
 
void setScale (const QwtInterval &)
 Specify a scale by interval
 
void setScale (const QwtScaleDiv &)
 Specify a scale by scale division
 
const QwtScaleDivscaleDiv () const
 Return the scale division
 
void setLowerBound (double value)
 Set the lower bound of the scale
 
double lowerBound () const
 Return the lower bound of the scale
 
void setUpperBound (double value)
 Set the upper bound of the scale
 
double upperBound () const
 Return the upper bound of the scale
 
void setScaleStepSize (double stepSize)
 Set the step size used for calculating scale division
 
double scaleStepSize () const
 Return the step size hint
 
void setScaleMaxMajor (int ticks)
 Set the maximum number of major tick intervals
 
int scaleMaxMinor () const
 Return the maximum number of minor tick intervals
 
void setScaleMaxMinor (int ticks)
 Set the maximum number of minor tick intervals
 
int scaleMaxMajor () const
 Return the maximum number of major tick intervals
 
void setScaleEngine (QwtScaleEngine *)
 Set the scale engine
 
const QwtScaleEnginescaleEngine () const
 Return the scale engine (const version)
 
QwtScaleEnginescaleEngine ()
 Return the scale engine (non-const version)
 
int transform (double) const
 Transform a scale value to widget coordinates
 
double invTransform (int) const
 Transform a widget coordinate to scale value
 
bool isInverted () const
 Check if scale is inverted
 
double minimum () const
 Return the minimum boundary
 
double maximum () const
 Return the maximum boundary
 
const QwtScaleMapscaleMap () const
 Return the scale map
 

Protected 成员函数

virtual void paintEvent (QPaintEvent *) override
 Repaint the knob
 
virtual void changeEvent (QEvent *) override
 Handle QEvent::StyleChange and QEvent::FontChange;
 
virtual void drawKnob (QPainter *, const QRectF &) const
 Draw the knob
 
virtual void drawFocusIndicator (QPainter *) const
 Draw the focus indicator
 
virtual void drawMarker (QPainter *, const QRectF &, double angle) const
 Draw the marker at the knob's front
 
virtual double scrolledTo (const QPoint &) const override
 Determine the value for a new position of the mouse
 
virtual bool isScrollPosition (const QPoint &) const override
 Determine what to do when the user presses a mouse button.
 
- Protected 成员函数 继承自 QwtAbstractSlider
virtual void mousePressEvent (QMouseEvent *) override
 Handle mouse press events (English only)
 
virtual void mouseReleaseEvent (QMouseEvent *) override
 Handle mouse release events (English only)
 
virtual void mouseMoveEvent (QMouseEvent *) override
 Handle mouse move events (English only)
 
virtual void keyPressEvent (QKeyEvent *) override
 Handle key press events (English only)
 
virtual void wheelEvent (QWheelEvent *) override
 Handle wheel events (English only)
 
void incrementValue (int stepCount)
 Increment the value by a number of steps (English only)
 
virtual void scaleChange () override
 Handle scale changes (English only)
 
virtual void sliderChange ()
 Handle slider changes (English only)
 
double incrementedValue (double value, int stepCount) const
 Calculate incremented value (English only)
 
- Protected 成员函数 继承自 QwtAbstractScale
void rescale (double lowerBound, double upperBound, double stepSize)
 Recalculate scale and update scale draw (English only)
 
void setAbstractScaleDraw (QwtAbstractScaleDraw *)
 Set the scale draw object (English only)
 
const QwtAbstractScaleDrawabstractScaleDraw () const
 Return the scale draw (const version) (English only)
 
QwtAbstractScaleDrawabstractScaleDraw ()
 Return the scale draw (non-const version) (English only)
 
void updateScaleDraw ()
 Update the scale draw (English only)
 

属性

KnobStyle knobStyle
 
int knobWidth
 
Qt::Alignment alignment
 
double totalAngle
 
int numTurns
 
MarkerStyle markerStyle
 
int markerSize
 
int borderWidth
 
- 属性 继承自 QwtAbstractSlider
double value
 
uint totalSteps
 
uint singleSteps
 
uint pageSteps
 
bool stepAlignment
 
bool readOnly
 
bool tracking
 
bool wrapping
 
bool invertedControls
 
- 属性 继承自 QwtAbstractScale
double lowerBound
 
double upperBound
 
int scaleMaxMajor
 
int scaleMaxMinor
 
double scaleStepSize
 

额外继承的成员函数

- Public 槽 继承自 QwtAbstractSlider
void setValue (double value)
 Set the slider value (English only)
 
- 信号 继承自 QwtAbstractSlider
void valueChanged (double value)
 Notify a change of value
 
void sliderPressed ()
 Signal emitted when the user presses the movable part of the slider
 
void sliderReleased ()
 Signal emitted when the user releases the movable part of the slider
 
void sliderMoved (double value)
 Signal emitted when the user moves the slider with the mouse
 

详细描述

The Knob Widget

The QwtKnob widget imitates look and behavior of a volume knob on a radio. It looks similar to QDial - not to QwtDial. The value range of a knob might be divided into several turns. The layout of the knob depends on the knobWidth():

成员枚举类型说明

◆ KnobStyle

Style of the knob surface

Depending on the KnobStyle the surface of the knob is filled from the brushes of the widget palette().

参见
setKnobStyle(), knobStyle()
枚举值
Flat 

Fill the knob with a brush from QPalette::Button

Raised 

Build a gradient from QPalette::Midlight and QPalette::Button

Sunken 

Build a gradient from QPalette::Midlight, QPalette::Button and QPalette::Midlight

Styled 

Build a radial gradient from QPalette::Button like QDial in various Qt styles

◆ MarkerStyle

Marker type

The marker indicates the current value on the knob. The default setting is a Notch marker.

参见
setMarkerStyle(), setMarkerSize()
枚举值
NoMarker 

Don't paint any marker

Tick 

Paint a single tick in QPalette::ButtonText color

Triangle 

Paint a triangle in QPalette::ButtonText color

Dot 

Paint a circle in QPalette::ButtonText color

Nub 

Draw a raised ellipse with a gradient from QPalette::Light and QPalette::Mid

Notch 

Draw a sunken ellipse with a gradient from QPalette::Light and QPalette::Mid

构造及析构函数说明

◆ QwtKnob()

QwtKnob::QwtKnob ( QWidget *  parent = nullptr)
explicit

Constructor

Construct a knob with an angle of 270°. The style is QwtKnob::Raised and the marker style is QwtKnob::Notch. The width of the knob is set to 50 pixels.

参数
parentParent widget
参见
setTotalAngle()

成员函数说明

◆ alignment()

Qt::Alignment QwtKnob::alignment ( ) const

Return alignment of the knob

Return alignment of the knob inside contentsRect()

返回
Alignment flags
参见
setAlignment(), knobWidth(), knobRect()

◆ changeEvent()

void QwtKnob::changeEvent ( QEvent *  event)
overrideprotectedvirtual

Handle QEvent::StyleChange and QEvent::FontChange;

参数
eventChange event

重载 QwtAbstractScale .

◆ drawFocusIndicator()

void QwtKnob::drawFocusIndicator ( QPainter *  painter) const
protectedvirtual

Draw the focus indicator

参数
painterPainter

◆ drawKnob()

void QwtKnob::drawKnob ( QPainter *  painter,
const QRectF &  knobRect 
) const
protectedvirtual

Draw the knob

参数
painterpainter
knobRectBounding rectangle of the knob (without scale)

◆ drawMarker()

void QwtKnob::drawMarker ( QPainter *  painter,
const QRectF &  rect,
double  angle 
) const
protectedvirtual

Draw the marker at the knob's front

参数
painterPainter
rectBounding rectangle of the knob without scale
angleAngle of the marker in degrees ( clockwise, 0 at the 12 o'clock position )

◆ isScrollPosition()

bool QwtKnob::isScrollPosition ( const QPoint &  pos) const
overrideprotectedvirtual

Determine what to do when the user presses a mouse button.

参数
posMouse position
返回值
True,whenpos is inside the circle of the knob.
参见
scrolledTo()

实现了 QwtAbstractSlider.

◆ knobRect()

QRect QwtKnob::knobRect ( ) const

Return the bounding rectangle of the knob

Calculate the bounding rectangle of the knob without the scale

返回
Bounding rectangle of the knob
参见
knobWidth(), alignment(), QWidget::contentsRect()

◆ knobStyle()

QwtKnob::KnobStyle QwtKnob::knobStyle ( ) const

Return the knob style

返回
Knob type
参见
setKnobStyle(), setBorderWidth()

◆ knobWidth()

int QwtKnob::knobWidth ( ) const

Return the knob's width

Return the width of the knob

◆ markerSize()

int QwtKnob::markerSize ( ) const

Return the marker size

返回
Marker size
参见
setMarkerSize()

◆ markerStyle()

QwtKnob::MarkerStyle QwtKnob::markerStyle ( ) const

Return the marker style

返回
Marker type of the knob
参见
setMarkerStyle(), setMarkerSize()

◆ minimumSizeHint()

QSize QwtKnob::minimumSizeHint ( ) const
overridevirtual

Return minimum size hint

Return the minimum size hint

返回
Minimum size hint
参见
sizeHint()

◆ numTurns()

int QwtKnob::numTurns ( ) const

Return the number of turns

返回
Number of turns. When the total angle is below 360°, numTurns() is ceiled to 1.
参见
setNumTurns(), setTotalAngle(), totalAngle()

◆ paintEvent()

void QwtKnob::paintEvent ( QPaintEvent *  event)
overrideprotectedvirtual

Repaint the knob

参数
eventPaint event

◆ scaleDraw() [1/2]

QwtRoundScaleDraw * QwtKnob::scaleDraw ( )

Return the scale draw (non-const version)

Return the scale draw of the knob (non-const version)

返回
The scale draw
参见
setScaleDraw()

◆ scaleDraw() [2/2]

const QwtRoundScaleDraw * QwtKnob::scaleDraw ( ) const

Return the scale draw (const version)

Return the scale draw of the knob (const version)

返回
The scale draw
参见
setScaleDraw()

◆ scrolledTo()

double QwtKnob::scrolledTo ( const QPoint &  pos) const
overrideprotectedvirtual

Determine the value for a new position of the mouse

参数
posMouse position
返回
Value for the mouse position
参见
isScrollPosition()

实现了 QwtAbstractSlider.

◆ setAlignment()

void QwtKnob::setAlignment ( Qt::Alignment  alignment)

Set alignment of the knob inside contentsRect()

Set the alignment of the knob

Similar to QLabel::alignment(), the flags decide how to align the knob inside of contentsRect(). The default setting is Qt::AlignCenter.

参数
alignmentOr'd alignment flags
参见
alignment(), setKnobWidth(), knobRect()

◆ setBorderWidth()

void QwtKnob::setBorderWidth ( int  borderWidth)

Set the border width

Set the knob's border width

参数
borderWidthNew border width

◆ setKnobStyle()

void QwtKnob::setKnobStyle ( KnobStyle  knobStyle)

Set the knob style

Set the knob type

参数
knobStyleKnob type
参见
knobStyle(), setBorderWidth()

◆ setKnobWidth()

void QwtKnob::setKnobWidth ( int  width)

Set the knob's width (diameter)

Change the knob's width

Setting a fixed value for the diameter of the knob is helpful for aligning several knobs in a row.

参数
widthNew width
参见
knobWidth(), setAlignment()
注解
Modifies the sizePolicy()

◆ setMarkerSize()

void QwtKnob::setMarkerSize ( int  size)

Set the marker size

Set the size of the marker

When setting a size <= 0 the marker will automatically be scaled to 40% of the radius of the knob.

参数
sizeMarker size
参见
markerSize(), markerStyle()

◆ setMarkerStyle()

void QwtKnob::setMarkerStyle ( MarkerStyle  markerStyle)

Set the marker style

Set the marker type of the knob

参数
markerStyleMarker type
参见
markerStyle(), setMarkerSize()

◆ setNumTurns()

void QwtKnob::setNumTurns ( int  numTurns)

Set the number of turns for the knob

Set the number of turns

When numTurns > 1 the knob can be turned several times around its axis. Otherwise the total angle is floored to 360°.

参数
numTurnsNumber of turns
参见
numTurns(), totalAngle(), setTotalAngle()

◆ setScaleDraw()

void QwtKnob::setScaleDraw ( QwtRoundScaleDraw scaleDraw)

Set the scale draw

Change the scale draw of the knob

For changing the labels of the scales, it is necessary to derive from QwtRoundScaleDraw and overload QwtRoundScaleDraw::label().

参数
scaleDrawScale draw object
参见
scaleDraw()

◆ setTotalAngle()

void QwtKnob::setTotalAngle ( double  angle)

Set the total angle which the knob can be turned

Set the total angle by which the knob can be turned

The angle has to be between [10, 360] degrees. Angles above 360 (so that the knob can be turned several times around its axis) have to be set using setNumTurns(). The default angle is 270 degrees.

参数
angleAngle in degrees
参见
totalAngle(), setNumTurns()

◆ sizeHint()

QSize QwtKnob::sizeHint ( ) const
overridevirtual

Return size hint

Return the size hint

返回
Size hint

◆ totalAngle()

double QwtKnob::totalAngle ( ) const

Return the total angle

返回
Total angle in degrees
参见
setTotalAngle(), setNumTurns(), numTurns()

该类的文档由以下文件生成: