QLCDNumber use

Disclaimer: This article original, without permission is forbidden. QQ group: QT & C / C ++ lovers 271251545 https://blog.csdn.net/xuancailinggan/article/details/77487705

QLCDNumber use

QLCDNumber similar control to display with a digital LCD display effect.

It can display virtually any size figures, supports decimal, hexadecimal, octal or binary display. Use display () slot can be easily connected to a data source, it is rewritten may receive five kinds of parameter types.

There are also a function of the groove may be modified hexadecimal format, such setModel to (), can also be used setSmallDecimalPoint Fixed decimal ().

When QLCDNumber displayed beyond what is required of its scope, it emits overflow () signal. The range () is set by setDigitCount, but setSmallDecimalPoint () also affect it.

If the display is set to hexadecimal, octal or binary, the conversion value is displayed as an integer.

These numbers may be displayed and the other symbols: 0 / 0,1,2,3,4,5 / S, 6,7,8,9 / g, a minus sign, decimal point, A, B, C, D, E, F , h, H, L, o, P, r, u, U, Y, colon, the degree symbol (designated as single characters in the string) and spaces. QLCDNumber replaces spaces with illegal characters.

Although you can use the value () to retrieve the value, but can not retrieve the content QLCDNumber object. If you really need to text, we recommend that you display () signal slot to connect to another tank, and stores it in there.

In addition, QLCDNumber is the oldest part of Qt, dating back to Sinclair Spectrum BASIC program.

Example 0049 set the display mode

QLCDNumber are the following modes:

setHexMode () - hexadecimal

setDecMode () - Decimal

setOctMode () - octal

setBinMode () - Binary

lcdNum->setDecMode();

As above, it will set the decimal mode, LCDNumber digital control mode to decimal

 

Example 0050 bits set at the display

lcdNum->setDigitCount(10);

It will be set up to Show 10 digits. Pay special attention to is that if your number is displayed decimal places, while more than 10 digits, and will not trigger the overflow signal, but to be wrong, to pay special attention in practice.

Example 0051 Fixed decimal whether placeholder

lcdNum->setSmallDecimalPoint(true);

If true, it would be a decimal point between the two figures exist, but do not account for a single position, if it is not set, the default is false , it will placeholder alone.

Example 0052 skinning and styling

// Set the display appearance

    lcdNum->setSegmentStyle(QLCDNumber::Flat);

    // set the style

   lcdNum->setStyleSheet("border:2pxsolidgreen;color:red;background:silver;");

Qt provides a variety of styles, you can be selected according to need:

Constant

Value

Description

QLCDNumber::Outline

0

gives raised segments filled with the background color.

QLCDNumber::Filled

1

gives raised segments filled with the windowText color.

QLCDNumber::Flat

2

gives flat segments filled with the windowText color.

Of course, this is clearly not enough, therefore a special case, do not forget that there setStyleSheet () function

Example overflow trigger signal 0053

The first is to establish a connection

connect(lcdNum,SIGNAL(overflow()),this,SLOT(onOverFlow()));

Slot function:

void MainWindow :: onOverFlow ()

{

    the this -> setWindowTitle ( " value out of range!" );

}

Simple trigger, realize that overflow when prompted to modify the title overflow (for brevity, does not use the information box).

Here, you can also try to test decimal overflow, there will be a lot of interesting things.

Welcome attention to micro-channel public number:




Guess you like

Origin blog.csdn.net/xuancailinggan/article/details/77487705
use
use