Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Classes  ·  Annotées  ·  Hiérarchie  ·  Fonctions  ·  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

Signals

Protected Members

  • virtual void drawContents ( QPainter * ) 

Properties

TypeNameREADWRITEOptions
boolsmallDecimalPointsmallDecimalPointsetSmallDecimalPoint 
intnumDigitsnumDigitssetNumDigits 
ModemodemodesetMode 
SegmentStylesegmentStylesegmentStylesetSegmentStyle 
doublevaluevaluedisplay 
intintValueintValuedisplay 

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-2005 Trolltech, all rights reserved.

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 94
  2. Apercevoir la troisième dimension ou l'utilisation multithreadée d'OpenGL dans Qt, un article des Qt Quarterly traduit par Guillaume Belz 0
  3. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  4. Pourquoi les programmeurs sont-ils moins payés que les gestionnaires de programmes ? Manquent-ils de pouvoir de négociation ? 42
  5. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  6. 2017 : un quinquennat pour une nouvelle version du C++ ? Possible, selon Herb Sutter 9
  7. Qt Commercial : Digia organise un webinar gratuit le 27 mars sur la conception d'interfaces utilisateur et d'applications avec le framework 0
Page suivante

Le Qt Developer Network au hasard

Logo

Une application d'ingénierie

Le Qt Developer Network est un réseau de développeurs Qt anglophone, où ils peuvent partager leur expérience sur le framework. Lire l'article.

Communauté

Ressources

Liens utiles

Contact

  • Vous souhaitez rejoindre la rédaction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

Qt dans le magazine

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt 2.3
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web