QwtKnob - The Knob Widget.
Contents
Constructor & Destructor Documentation
QwtKnob::QwtKnob(QWidget*parent=NULL)[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.
Parameters:parent Parent widget
Seealso:setTotalAngle()Detailed Description
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().
• width > 0 The diameter of the knob is fixed and the knob is aligned according to the alignment() flags
inside of the contentsRect().
• width <= 0 The knob is extended to the minimum of width/height of the contentsRect() and aligned in the
other direction according to alignment().
Setting a fixed knobWidth() is helpful to align several knobs with different scale labels.
Member Enumeration Documentation
enumQwtKnob::KnobStyle
Style of the knob surface. Depending on the KnobStyle the surface of the knob is filled from the brushes
of the widget palette().
Seealso:setKnobStyle(), knobStyle()EnumeratorFlat 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 it is used for QDial in various Qt styles.
enumQwtKnob::MarkerStyle
Marker type. The marker indicates the current value on the knob The default setting is a Notch marker.
Seealso:setMarkerStyle(), setMarkerSize()EnumeratorNoMarker
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 build from QPalette::Light and QPalette::Mid
Notch Draw a sunken ellipse with a gradient build from QPalette::Light and QPalette::Mid
Member Function Documentation
Qt::AlignmentQwtKnob::alignment()constReturns:
Alignment of the knob inside of contentsRect()
Seealso:setAlignment(), knobWidth(), knobRect()voidQwtKnob::changeEvent(QEvent*event)[protected],[virtual]
Handle QEvent::StyleChange and QEvent::FontChange;
Parameters:event Change event
voidQwtKnob::drawFocusIndicator(QPainter*painter)const[protected],[virtual]
Draw the focus indicator
Parameters:painter Painter
voidQwtKnob::drawKnob(QPainter*painter,constQRectF&knobRect)const[protected],[virtual]
Draw the knob.
Parameters:painter painter
knobRect Bounding rectangle of the knob (without scale)
voidQwtKnob::drawMarker(QPainter*painter,constQRectF&rect,doubleangle)const[protected],[virtual]
Draw the marker at the knob's front.
Parameters:painter Painter
rect Bounding rectangle of the knob without scale
angle Angle of the marker in degrees ( clockwise, 0 at the 12 o'clock position )
boolQwtKnob::isScrollPosition(constQPoint&pos)const[protected],[virtual]
Determine what to do when the user presses a mouse button.
Parameters:pos Mouse position
Returnvalues:True,when pos is inside the circle of the knob.
Seealso:scrolledTo()
Implements QwtAbstractSlider.
QRectQwtKnob::knobRect()const
Calculate the bounding rectangle of the knob without the scale
Returns:
Bounding rectangle of the knob
Seealso:knobWidth(), alignment(), QWidget::contentsRect()
QwtKnob::KnobStyleQwtKnob::knobStyle()constReturns:
Marker type of the knob
Seealso:setKnobStyle(), setBorderWidth()intQwtKnob::markerSize()constReturns:
Marker size
Seealso:setMarkerSize()QwtKnob::MarkerStyleQwtKnob::markerStyle()constReturns:
Marker type of the knob
Seealso:setMarkerStyle(), setMarkerSize()QSizeQwtKnob::minimumSizeHint()const[virtual]Returns:
Minimum size hint
Seealso:sizeHint()intQwtKnob::numTurns()constReturns:
Number of turns.
When the total angle is below 360° numTurns() is ceiled to 1.
Seealso:setNumTurns(), setTotalAngle(), totalAngle()voidQwtKnob::paintEvent(QPaintEvent*event)[protected],[virtual]
Repaint the knob
Parameters:event Paint event
constQwtRoundScaleDraw*QwtKnob::scaleDraw()constReturns:
the scale draw of the knob
Seealso:setScaleDraw()QwtRoundScaleDraw*QwtKnob::scaleDraw()Returns:
the scale draw of the knob
Seealso:setScaleDraw()doubleQwtKnob::scrolledTo(constQPoint&pos)const[protected],[virtual]
Determine the value for a new position of the mouse.
Parameters:pos Mouse position
Returns:
Value for the mouse position
Seealso:isScrollPosition()
Implements QwtAbstractSlider.
voidQwtKnob::setAlignment(Qt::Alignmentalignment)
Set the alignment of the knob. Similar to a QLabel::alignment() the flags decide how to align the knob
inside of contentsRect().
The default setting is Qt::AlignCenter
Parameters:alignment Or'd alignment flags
Seealso:alignment(), setKnobWidth(), knobRect()voidQwtKnob::setBorderWidth(intborderWidth)
Set the knob's border width.
Parameters:borderWidth new border width
voidQwtKnob::setKnobStyle(KnobStyleknobStyle)
Set the knob type.
Parameters:knobStyle Knob type
Seealso:knobStyle(), setBorderWidth()voidQwtKnob::setKnobWidth(intwidth)
Change the knob's width. Setting a fixed value for the diameter of the knob is helpful for aligning
several knobs in a row.
Parameters:width New width
Seealso:knobWidth(), setAlignment()Note:
Modifies the sizePolicy()
voidQwtKnob::setMarkerSize(intsize)
Set the size of the marker. When setting a size <= 0 the marker will automatically scaled to 40% of the
radius of the knob.
Seealso:markerSize(), markerStyle()voidQwtKnob::setMarkerStyle(MarkerStylemarkerStyle)
Set the marker type of the knob.
Parameters:markerStyle Marker type
Seealso:markerStyle(), setMarkerSize()voidQwtKnob::setNumTurns(intnumTurns)
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°.
Seealso:numTurns(), totalAngle(), setTotalAngle()voidQwtKnob::setScaleDraw(QwtRoundScaleDraw*scaleDraw)
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().
Seealso:scaleDraw()voidQwtKnob::setTotalAngle(doubleangle)
Set the total angle by which the knob can be turned.
Parameters:angle Angle in degrees.
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.
Seealso:totalAngle(), setNumTurns()QSizeQwtKnob::sizeHint()const[virtual]Returns:sizeHint()doubleQwtKnob::totalAngle()constReturns:
the total angle
Seealso:setTotalAngle(), setNumTurns(), numTurns()Name
QwtKnob - The Knob Widget.
Synopsis
#include <qwt_knob.h>
Inherits QwtAbstractSlider.
PublicTypes
enum KnobStyle { Flat, Raised, Sunken, Styled }
Style of the knob surface.
enum MarkerStyle { NoMarker = -1, Tick, Triangle, Dot, Nub, Notch }
Marker type.
PublicMemberFunctionsQwtKnob (QWidget *parent=NULL)
Constructor.
virtual ~QwtKnob ()
Destructor.
void setAlignment (Qt::Alignment)
Set the alignment of the knob.
Qt::Alignment alignment () const
void setKnobWidth (int)
Change the knob's width.
int knobWidth () const
Return the width of the knob.
void setNumTurns (int)
Set the number of turns.
int numTurns () const
void setTotalAngle (double angle)
Set the total angle by which the knob can be turned.
double totalAngle () const
void setKnobStyle (KnobStyle)
Set the knob type.
KnobStyleknobStyle () const
void setBorderWidth (int)
Set the knob's border width.
int borderWidth () const
Return the border width.
void setMarkerStyle (MarkerStyle)
Set the marker type of the knob.
MarkerStylemarkerStyle () const
void setMarkerSize (int)
Set the size of the marker.
int markerSize () const
virtual QSize sizeHint () const
virtual QSize minimumSizeHint () const
void setScaleDraw (QwtRoundScaleDraw *)
const QwtRoundScaleDraw * scaleDraw () const
QwtRoundScaleDraw * scaleDraw ()
QRect knobRect () const
ProtectedMemberFunctions
virtual void paintEvent (QPaintEvent *)
virtual void changeEvent (QEvent *)
virtual void drawKnob (QPainter *, const QRectF &) const
Draw the knob.
virtual void drawFocusIndicator (QPainter *) const
virtual void drawMarker (QPainter *, const QRectF &, double angle) const
Draw the marker at the knob's front.
virtual double scrolledTo (const QPoint &) const
Determine the value for a new position of the mouse.
virtual bool isScrollPosition (const QPoint &) const
Determine what to do when the user presses a mouse button.
AdditionalInheritedMembers