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

# QLCDNumber Class Reference

The QLCDNumber widget displays a number with LCD-like digits. More...

`#include <qlcdnumber.h>`

Inherits QFrame.

List of all member functions.

## Public Members

- QLCDNumber ( QWidget * parent=0, const char * name=0 )
- QLCDNumber ( uint numDigits, QWidget * parent=0, const char * name=0 )
- ~QLCDNumber ()
- enum Mode { Hex, HEX=Hex, Dec, DEC=Dec, Oct, OCT=Oct, Bin, BIN=Bin }
- enum SegmentStyle { Outline, Filled, Flat }
- bool smallDecimalPoint () const
- int numDigits () const
- virtual void setNumDigits ( int nDigits )
- bool checkOverflow ( double num ) const
- bool checkOverflow ( int num ) const
- Mode mode () const
- virtual void setMode ( Mode )
- SegmentStyle segmentStyle () const
- virtual void setSegmentStyle ( SegmentStyle )
- double value () const
- int intValue () const

## Public Slots

- void display ( int num )
- void display ( double num )
- void display ( const QString & str )
- virtual void setHexMode ()
- virtual void setDecMode ()
- virtual void setOctMode ()
- virtual void setBinMode ()
- virtual void setSmallDecimalPoint ( bool )

## Signals

- void overflow ()

## Protected Members

- virtual void drawContents ( QPainter * )

## Properties

Type | Name | READ | WRITE | Options
--- | --- | --- | --- | ---
bool | smallDecimalPoint | smallDecimalPoint | setSmallDecimalPoint |
int | numDigits | numDigits | setNumDigits |
Mode | mode | mode | setMode |
SegmentStyle | segmentStyle | segmentStyle | setSegmentStyle |
double | value | value | display |
int | intValue | intValue | display |

## Detailed Description

The QLCDNumber widget displays a number with LCD-like digits.

It can display a number in just about any size, in decimal, hexadecimal, octal or binary notation, and is easy to connect to data sources via the display() slot, which is overloaded to take any of five argument types.

There are also slots to change the notation mode and decimal point mode.

QLCDNumber emits the overflow() signal when it is asked to display something beyond its range. The range is set by setNumDigits() (but setSmallDecimalPoint() influences it too).

These digits and other symbols can be shown: 0/O, 1, 2, 3, 4, 5/S, 6, 7, 8, 9/g, minus, decimal point, A, B, C, D, E, F, h, H, L, o, P, r, u, U, Y, colon, degree sign (which is specified as single quote in the string) and space. QLCDNumber substitutes spaces for illegal characters.

It is not possible to retrieve the contents of a QLCDNumber object. If you need to, we recommend that you connect the signals which feed the display() slot to another slot as well and store the value there.

Incidentally, QLCDNumber is the very oldest part of Qt, tracing back to a BASIC program on the Sinclair Spectrum.

See also QLabel and QFrame.

Examples: xform/xform.cpp

## Member Type Documentation

### QLCDNumber::Mode

This type determines how numbers are shown. The possible values are:

- `Hex` - Hexadecimal
- `Dec` - Decimal
- `Oct` - Octal
- `Bin` - Binary

### QLCDNumber::SegmentStyle

This type determines the visual appearance of the QLCDNumber widget. The possible values are:

- `Outline` gives raised segments filled with the background brush.
- `Filled` gives raised segments filled with the foreground brush.
- `Flat` gives flat segments filled with the foreground brush.

## Member Function Documentation

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

Constructs an LCD number, sets the number of digits to 5, the base to decimal, the decimal point mode to 'small' and the frame style to a raised box. The segmentStyle() is set to `Outline.`

The parent and name arguments are passed to the QFrame constructor.

See also setNumDigits() and setSmallDecimalPoint().

### QLCDNumber::QLCDNumber ( uint numDigits, QWidget * parent=0, const char * name=0 )

Constructs an LCD number, sets the number of digits to numDigits, the base to decimal, the decimal point mode to 'small' and the frame style to a raised box. The segmentStyle() is set to `Outline.`

The parent and name arguments are passed to the QFrame constructor.

See also setNumDigits() and setSmallDecimalPoint().

### QLCDNumber::~QLCDNumber ()

Destructs the LCD number.

### bool QLCDNumber::checkOverflow ( double num ) const

Returns TRUE if num is too big to be displayed in its entirety, FALSE otherwise.

See also display(), numDigits() and smallDecimalPoint().

### bool QLCDNumber::checkOverflow ( int num ) const

Returns TRUE if num is too big to be displayed in its entirety, FALSE otherwise.

See also display(), numDigits() and smallDecimalPoint().

### void QLCDNumber::display ( int num ) `[slot]`

Sets the contents of the display to num.

See also setMode() and smallDecimalPoint().

Examples: xform/xform.cpp

### void QLCDNumber::display ( const QString & s ) `[slot]`

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

This version of the function disregards mode() and smallDecimalPoint().

These digits and other symbols can be shown: 0/O, 1, 2, 3, 4, 5/S, 6, 7, 8, 9/g, minus, decimal point, A, B, C, D, E, F, h, H, L, o, P, r, u, U, Y, colon, degree sign (which is specified as single quote in the string) and space. QLCDNumber substitutes spaces for illegal characters.

### void QLCDNumber::display ( double num ) `[slot]`

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

### void QLCDNumber::drawContents ( QPainter * p ) `[virtual protected]`

Draws the LCD number using painter p. This function is called from QFrame::paintEvent().

Reimplemented from QFrame.

### int QLCDNumber::intValue () const

Returns the last value set by one of the display() slots rounded to the nearest integer.

If display(QString ) was the last called, 0 is returned.

See also value() and display().

### QLCDNumber::Mode QLCDNumber::mode() const

Returns the current display mode, which is one of `BIN, OCT, DEC` and `HEX.`

See also setMode() and smallDecimalPoint().

### int QLCDNumber::numDigits () const

Returns the current number of digits. If smallDecimalPoint() is FALSE, the decimal point occupies one digit position.

See also setNumDigits() and smallDecimalPoint().

### void QLCDNumber::overflow () `[signal]`

This signal is emitted whenever the QLCDNumber is asked to display a too large number or a too long string.

It is never emitted by setNumDigits().

### QLCDNumber::SegmentStyle QLCDNumber::segmentStyle() const

Returns the style of the QLCDNumber.

See also setSegmentStyle().

### void QLCDNumber::setBinMode () `[virtual slot]`

Calls setMode( BIN ). Provided for convenience (e.g. for connecting buttons to this).

See also setMode(), setHexMode(), setDecMode(), setOctMode() and mode().

### void QLCDNumber::setDecMode () `[virtual slot]`

Calls setMode( DEC ). Provided for convenience (e.g. for connecting buttons to this).

See also setMode(), setHexMode(), setOctMode(), setBinMode() and mode().

### void QLCDNumber::setHexMode () `[virtual slot]`

Calls setMode( HEX ). Provided for convenience (e.g. for connecting buttons to this).

See also setMode(), setDecMode(), setOctMode(), setBinMode() and mode().

### void QLCDNumber::setMode ( Mode m )

Sets the display mode to m, which must be one of `BIN, OCT, DEC` and `HEX.` All four modes can display both integers, floating-point numbers and strings (subject to character set limitations).

Example:

        myLcd.setMode( QLCDNumber::HEX );

See also mode(), setHexMode(), setDecMode(), setOctMode(), setBinMode(), setSmallDecimalPoint() and display().

### void QLCDNumber::setNumDigits ( int numDigits ) `[virtual]`

Sets the number of digits shown to numDigits, which is forced into the [0-99] range.

If smallDecimalPoint() is TRUE, numDigits can be shown. If it is FALSE, only numDigits-1 digits can be shown.

See also numDigits(), setMode(), setSmallDecimalPoint() and overflow().

### void QLCDNumber::setOctMode () `[virtual slot]`

Calls setMode( OCT ). Provided for convenience (e.g. for connecting buttons to this).

See also setMode(), setHexMode(), setDecMode(), setBinMode() and mode().

### void QLCDNumber::setSegmentStyle ( SegmentStyle s )

Sets the style of the QLCDNumber to s.

- `Outline` gives raised segments filled with the background color.
- `Filled` gives raised segments filled with the foreground color.
- `Flat` gives flat segments filled with the foreground color.

`Outline` and `Filled` will additionally use QColorGroup::light() and QColorGroup::dark() for shadow effects.

See also segmentStyle().

### void QLCDNumber::setSmallDecimalPoint ( bool b ) `[virtual slot]`

If b is TRUE, the decimal point is drawn between two digits. If b is FALSE, the decimal point is drawn in a digit position.

The inter-digit space is made slightly wider when the decimal point is drawn between the digits.

See also smallDecimalPoint() and setMode().

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

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

### QSizePolicy QLCDNumber::sizePolicy () const `[virtual]`

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

### bool QLCDNumber::smallDecimalPoint () const

Returns TRUE if the decimal point is currently drawn between two digit positions, and FALSE if it is drawn in a digit position.

See also setSmallDecimalPoint() and mode().

### double QLCDNumber::value () const

Returns the last value set by one of the display() slots.

If display(QString ) was the last called, 0 is returned.

See also intValue() and display().

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

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