# 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 ()
- bool smallDecimalPoint () const
- int numDigits () const
- void setNumDigits ( int nDigits )
- bool checkOverflow ( double num ) const
- bool checkOverflow ( int num ) const
- Mode mode () const
- void setMode ( Mode )
- SegmentStyle segmentStyle () const
- void setSegmentStyle ( SegmentStyle )
- double value () const
- int intValue () const
- virtual QSize sizeHint () const

## Public Slots

- void display ( int num )
- void display ( double num )
- void display ( const char * str )
- void setHexMode ()
- void setDecMode ()
- void setOctMode ()
- void setBinMode ()
- void setSmallDecimalPoint ( bool )

## Signals

- void overflow ()

## Protected Members

- virtual void resizeEvent ( QResizeEvent * )
- virtual void drawContents ( QPainter * )

## 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 impossible 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.

Warning: The current version of QLCDNumber does not work well with background pixmaps.

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: dclock/dclock.cpp xform/xform.cpp

## 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 ()

Destroys 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: dclock/dclock.cpp xform/xform.cpp

### void QLCDNumber::display ( const char * 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(const char *) 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().

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

Handles resize Events for the QLCDNumber.

Reimplemented from QWidget.

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

Returns the style of the QLCDNumber.

See also: setSegmentStyle().

### void QLCDNumber::setBinMode () `[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 () `[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 () `[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).

The display is set to "0".

Example:

        myLcd.setMode( QLCDNumber::HEX );

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

### void QLCDNumber::setNumDigits ( int numDigits )

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 () `[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 ) `[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.

The display is set to "0.0".

See also: smallDecimalPoint() and setMode().

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

Returns a suitable size for this LCD number. The size hint is on the small side, so as to be usable as minimum size.

The size hint takes numDigits() and smallDecimalPoint() into consideration.

See also: setNumDigits(), setSmallDecimalPoint() and setMinimumSize().

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(const char *) was the last called, 0 is returned.

See also: intValue() and display().

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

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

It was generated from the following files:

- qlcdnumber.h: 1998/08/21
- qlcdnumber.cpp: 1998/08/19