| Classes - Annotated - Tree - Functions - Home - Structure

# QDial Class Reference

The QDial class provides a rounded rangecontrol (like a speedometer or potentiometer). More...

`#include <qdial.h>`

Inherits QRangeControl and QWidget.

List of all member functions.

## Public Members

- QDial ( QWidget * parent=0, const char * name=0 )
- QDial ( int minValue, int maxValue, int pageStep, int value, QWidget * parent=0, const char * name=0 )
- ~QDial ()
- bool tracking () const
- bool wrapping () const
- int notchSize () const
- virtual void setNotchTarget ( double )
- double notchTarget () const
- bool notchesVisible () const
- void setMinValue ( int )
- void setMaxValue ( int )
- void setLineStep ( int )
- void setPageStep ( int )

## Public Slots

- virtual void setValue ( int )
- void addLine ()
- void subtractLine ()
- void addPage ()
- void subtractPage ()
- virtual void setNotchesVisible ( bool b )
- virtual void setWrapping ( bool on )
- virtual void setTracking ( bool enable )

## Signals

- void valueChanged ( int value )
- void dialPressed ()
- void dialMoved ( int value )
- void dialReleased ()

## Protected Members

- virtual void valueChange ()
- virtual void rangeChange ()
- virtual void repaintScreen ( const QRect * cr = 0 )

## Properties

Type | Name | READ | WRITE | Options
--- | --- | --- | --- | ---
bool | tracking | tracking | setTracking |
bool | wrapping | wrapping | setWrapping |
int | notchSize | notchSize |  |
double | notchTarget | notchTarget | setNotchTarget |
bool | notchesVisible | notchesVisible | setNotchesVisible |
int | minValue | minValue | setMinValue |
int | maxValue | maxValue | setMaxValue |
int | lineStep | lineStep | setLineStep |
int | pageStep | pageStep | setPageStep |
int | value | value | setValue |

## Detailed Description

The QDial class provides a rounded rangecontrol (like a speedometer or potentiometer).

Q dial is used when the user needs to control a value within a program-definable range, and the range either wraps around (typically, 0-359 degrees) or the dialog layout needs a square widget.

Both API- and UI-wise, the dial is very like a slider. Indeed, when wrapping() is FALSE (the default) there is no hard difference between a slider and a dial. They have the same signals, slots and member functions, all of which do the same things. Which one to use depends only on your taste and on the application.

The dial initially emits valueChanged() signals continuously while the slider is being moved; you can make it emit the signal less often by calling setTracking( FALSE ). dialMoved() is emitted continuously even when tracking() is FALSE.

The slider also emits dialPressed() and dialReleased() signals when the mouse button is pressed and released. But note that the dial's value can change without these signals being emitted; the keyboard and wheel can be used to change the value.

Unlike the slider, QDial attempts to draw a "nice" number of notches rather than one per lineStep(). If possible, that number is lineStep(), but if there aren't enough pixels to draw every, QDial will draw every second, third or something. notchSize() returns the number of units per notch, hopefully a multiple of lineStep(); setNotchTarget() sets the target distance between neighbouring notches in pixels. The default is 3.75 pixels.

Like the slider, the dial makes the QRangeControl functions setValue(), addLine(), substractLine(), addPage() and subtractPage() available as slots.

The dial's keyboard interface is fairly simple: The left/up and right/down arrow keys move by lineStep(), page up and page down by pageStep() and Home and End to minValue() and maxValue().

See also QScrollBar, QSpinBox and GUI Design Handbook: Slider

## Member Function Documentation

### QDial::QDial ( QWidget * parent=0, const char * name=0 )

Constructs a dial with the default range of QRangeControl.

### QDial::QDial ( int minValue, int maxValue, int pageStep, int value, QWidget * parent=0, const char * name=0 )

Constructs a dial whose value can never be smaller than minValue or greater than maxValue, whose line step size is lineStep and page step size is pageStep, and whose value is initially value.

value is forced to be within the legal range.

### QDial::~QDial ()

Destructs the dial.

### void QDial::addLine () `[slot]`

Moves the dial one lineStep() upwards.

### void QDial::addPage () `[slot]`

Moves the dial one pageStep() upwards.

### void QDial::dialMoved ( int value ) `[signal]`

This signal is emitted whenever the dial value changes. The frequency of this signal is not influenced by setTracking().

See also valueChanged(int).

### void QDial::dialPressed () `[signal]`

This signal is emitted when the use begins mouse interaction with the dial.

See also dialReleased().

### void QDial::dialReleased () `[signal]`

This signal is emitted when the use ends mouse interaction with the dial.

See also dialPressed().

### void QDial::focusInEvent ( QFocusEvent * ) `[virtual protected]`

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

### void QDial::focusOutEvent ( QFocusEvent * ) `[virtual protected]`

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

### void QDial::keyPressEvent ( QKeyEvent * e ) `[virtual protected]`

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

### int QDial::lineStep () const

Reimplemented for internal reasons; the API is not affected.

### int QDial::maxValue () const

Reimplemented for internal reasons; the API is not affected.

### int QDial::minValue () const

Reimplemented for internal reasons; the API is not affected.

### QSize QDial::minimumSizeHint () const `[virtual]`

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

### void QDial::mouseMoveEvent ( QMouseEvent * e ) `[virtual protected]`

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

### void QDial::mousePressEvent ( QMouseEvent * e ) `[virtual protected]`

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

### void QDial::mouseReleaseEvent ( QMouseEvent * e ) `[virtual protected]`

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

### int QDial::notchSize () const

Returns the current notch size. This is in range control units, not pixels, and if possible it is a multiple of lineStep() that results in an on-screen notch size near notchTarget().

See also notchTarget() and lineStep().

### double QDial::notchTarget () const

Returns the target size of the notch; this is the number of pixels QDial attempts to put between each little line.

The actual size differs a bit from the target.

### bool QDial::notchesVisible () const

Retuns TRUE if notches are shown, else FALSE.

See also setNotchesVisible().

### int QDial::pageStep () const

Reimplemented for internal reasons; the API is not affected.

### void QDial::paintEvent ( QPaintEvent * e ) `[virtual protected]`

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

### void QDial::rangeChange () `[virtual protected]`

Reimplemented to ensure tick-marks are consistent with the new range.

Reimplemented from QRangeControl.

### void QDial::repaintScreen ( const QRect * cr = 0 ) `[virtual protected]`

Paints the dial.

### void QDial::resizeEvent ( QResizeEvent * e ) `[virtual protected]`

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

### void QDial::setLineStep ( int i )

Sets the line step to i.

Calls the virtual stepChange() function if the new line step is different from the previous setting.

See also lineStep(), QRangeControl::setSteps(), setPageStep() and setRange().

### void QDial::setMaxValue ( int i )

A convenience function which just calls setRange( minValue(), i )

See also setRange().

### void QDial::setMinValue ( int i )

A convenience function which just calls setRange( i, maxValue() )

See also setRange().

### void QDial::setNotchTarget ( double target ) `[virtual]`

Sets the dial to use a notch size as close to target pixels as possible. QDial will find a suitable number close to this, based on the dial's on-screen size, range and lineStep().

See also notchTarget() and notchSize().

### void QDial::setNotchesVisible ( bool b ) `[virtual slot]`

Enables or disables showing of notches. If b is TRUE, the notches are shown, else not.

### void QDial::setPageStep ( int i )

Sets the page step to i.

Calls the virtual stepChange() function if the new page step is different from the previous setting.

See also pageStep(), QRangeControl::setSteps(), setLineStep() and setRange().

### void QDial::setTracking ( bool enable ) `[virtual slot]`

If enable is TRUE, tracking is enabled. This means that the arrow can be moved using the mouse. Else this is not possible.

### void QDial::setValue ( int newValue ) `[virtual slot]`

Makes QRangeControl::setValue() available as a slot.

### void QDial::setWrapping ( bool enable ) `[virtual slot]`

If enable is TRUE, wrapping is enabled. This means that the arrow can be turned around 360°. Else there is some space at the bottom which is skipped by the arrow.

### QSize QDial::sizeHint () const `[virtual]`

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

### void QDial::subtractLine () `[slot]`

Moves the dial one lineStep() downwards.

### void QDial::subtractPage () `[slot]`

Moves the dial one pageStep() downwards.

### bool QDial::tracking () const

Returns TRUE if tracking is enabled, or FALSE if tracking is disabled.

Tracking is initially enabled.

See also setTracking().

### int QDial::value () const

Reimplemented for internal reasons; the API is not affected.

### void QDial::valueChange () `[virtual protected]`

Reimplemented to ensure the display is correct and to emit the valueChanged(int) signal when appropriate.

Reimplemented from QRangeControl.

### void QDial::valueChanged ( int value ) `[signal]`

This signal is emitted whenever the dial value changes. The frequency of this signal is influenced by setTracking().

### void QDial::wheelEvent ( QWheelEvent * e ) `[virtual protected]`

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

### bool QDial::wrapping () const

Returns TRUE if wrapping is enabled, else FALSE.

See also QDial::setWrapping().

Search the documentation, FAQ, qt-interest archive and more (uses www.trolltech.com):

This file is part of the Qt toolkit, copyright © 1995-2000 Trolltech, all rights reserved.