Qt logo

QDial Class Reference


The QDial widget provides a dial (or speedometer, or potentiometer) widget. More...

#include <qdial.h>

Inherits QRangeControl and QWidget.

List of all member functions.

Public Members

Public Slots

Signals

Protected Members


Detailed Description

The QDial widget provides a dial (or speedometer, or potentiometer) widget.

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.

QSize QDial::minimumSize () const

Reimplemented for internal reasons; the API is not affected.

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.

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

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

void QDial::repaintScreen ( const QRect * cr = 0 ) [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::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::setShowNotches ( bool b )

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

void QDial::setTracking ( bool enable ) [virtual]

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]

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.

bool QDial::showNotches ()

Retuns TRUE if notches are shown, else FALSE;.

QSize QDial::sizeHint () const [virtual]

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

QSizePolicy QDial::sizePolicy () 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().

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.troll.no):


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


Copyright © 2000 Troll TechTrademarks
Qt version 2.1.0 (pre-release)