You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
qt3/doc/html/qlcdnumber.html

333 lines
20 KiB

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/widgets/qlcdnumber.cpp:44 -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>QLCDNumber Class</title>
<style type="text/css"><!--
fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
body { background: #ffffff; color: black; }
--></style>
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr bgcolor="#E5E5E5">
<td valign=center>
<a href="index.html">
<font color="#004faf">Home</font></a>
| <a href="classes.html">
<font color="#004faf">All&nbsp;Classes</font></a>
| <a href="mainclasses.html">
<font color="#004faf">Main&nbsp;Classes</font></a>
| <a href="annotated.html">
<font color="#004faf">Annotated</font></a>
| <a href="groups.html">
<font color="#004faf">Grouped&nbsp;Classes</font></a>
| <a href="functions.html">
<font color="#004faf">Functions</font></a>
</td>
<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QLCDNumber Class Reference</h1>
<p>The QLCDNumber widget displays a number with LCD-like digits.
<a href="#details">More...</a>
<p><tt>#include &lt;<a href="qlcdnumber-h.html">qlcdnumber.h</a>&gt;</tt>
<p>Inherits <a href="qframe.html">QFrame</a>.
<p><a href="qlcdnumber-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li class=fn><a href="#QLCDNumber"><b>QLCDNumber</b></a> ( QWidget&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0 )</li>
<li class=fn><a href="#QLCDNumber-2"><b>QLCDNumber</b></a> ( uint&nbsp;numDigits, QWidget&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0 )</li>
<li class=fn><a href="#~QLCDNumber"><b>~QLCDNumber</b></a> ()</li>
<li class=fn>enum <a href="#Mode-enum"><b>Mode</b></a> { Hex, Dec, Oct, Bin, HEX = Hex, DEC = Dec, OCT = Oct, BIN = Bin }</li>
<li class=fn>enum <a href="#SegmentStyle-enum"><b>SegmentStyle</b></a> { Outline, Filled, Flat }</li>
<li class=fn>bool <a href="#smallDecimalPoint"><b>smallDecimalPoint</b></a> () const</li>
<li class=fn>int <a href="#numDigits"><b>numDigits</b></a> () const</li>
<li class=fn>virtual void <a href="#setNumDigits"><b>setNumDigits</b></a> ( int&nbsp;nDigits )</li>
<li class=fn>bool <a href="#checkOverflow"><b>checkOverflow</b></a> ( double&nbsp;num ) const</li>
<li class=fn>bool <a href="#checkOverflow-2"><b>checkOverflow</b></a> ( int&nbsp;num ) const</li>
<li class=fn>Mode <a href="#mode"><b>mode</b></a> () const</li>
<li class=fn>virtual void <a href="#setMode"><b>setMode</b></a> ( Mode )</li>
<li class=fn>SegmentStyle <a href="#segmentStyle"><b>segmentStyle</b></a> () const</li>
<li class=fn>virtual void <a href="#setSegmentStyle"><b>setSegmentStyle</b></a> ( SegmentStyle )</li>
<li class=fn>double <a href="#value"><b>value</b></a> () const</li>
<li class=fn>int <a href="#intValue"><b>intValue</b></a> () const</li>
</ul>
<h2>Public Slots</h2>
<ul>
<li class=fn>void <a href="#display"><b>display</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;s )</li>
<li class=fn>void <a href="#display-2"><b>display</b></a> ( int&nbsp;num )</li>
<li class=fn>void <a href="#display-3"><b>display</b></a> ( double&nbsp;num )</li>
<li class=fn>virtual void <a href="#setHexMode"><b>setHexMode</b></a> ()</li>
<li class=fn>virtual void <a href="#setDecMode"><b>setDecMode</b></a> ()</li>
<li class=fn>virtual void <a href="#setOctMode"><b>setOctMode</b></a> ()</li>
<li class=fn>virtual void <a href="#setBinMode"><b>setBinMode</b></a> ()</li>
<li class=fn>virtual void <a href="#setSmallDecimalPoint"><b>setSmallDecimalPoint</b></a> ( bool )</li>
</ul>
<h2>Signals</h2>
<ul>
<li class=fn>void <a href="#overflow"><b>overflow</b></a> ()</li>
</ul>
<h2>Properties</h2>
<ul>
<li class=fn>int <a href="#intValue-prop"><b>intValue</b></a>&nbsp;- the displayed value rounded to the nearest integer</li>
<li class=fn>Mode <a href="#mode-prop"><b>mode</b></a>&nbsp;- the current display mode (number base)</li>
<li class=fn>int <a href="#numDigits-prop"><b>numDigits</b></a>&nbsp;- the current number of digits displayed</li>
<li class=fn>SegmentStyle <a href="#segmentStyle-prop"><b>segmentStyle</b></a>&nbsp;- the style of the LCDNumber</li>
<li class=fn>bool <a href="#smallDecimalPoint-prop"><b>smallDecimalPoint</b></a>&nbsp;- the style of the decimal point</li>
<li class=fn>double <a href="#value-prop"><b>value</b></a>&nbsp;- the displayed value</li>
</ul>
<h2>Protected Members</h2>
<ul>
<li class=fn>virtual void <a href="#drawContents"><b>drawContents</b></a> ( QPainter&nbsp;*&nbsp;p )</li>
</ul>
<hr><a name="details"></a><h2>Detailed Description</h2>
<p> The QLCDNumber widget displays a number with LCD-like digits.
<p>
<p> It can display a number in just about any size. It can display
decimal, hexadecimal, octal or binary numbers. It is easy to
connect to data sources using the <a href="#display">display</a>() slot, which is
overloaded to take any of five argument types.
<p> There are also slots to change the base with <a href="#setMode">setMode</a>() and the
decimal point with <a href="#setSmallDecimalPoint">setSmallDecimalPoint</a>().
<p> QLCDNumber emits the <a href="#overflow">overflow</a>() signal when it is asked to display
something beyond its range. The range is set by <a href="#setNumDigits">setNumDigits</a>(),
but setSmallDecimalPoint() also influences it. If the display is
set to hexadecimal, octal or binary, the integer equivalent of the
value is displayed.
<p> 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.
<p> It is not possible to retrieve the contents of a QLCDNumber
object, although you can retrieve the numeric value with <a href="#value">value</a>().
If you really need the text, we recommend that you connect the
signals that feed the <a href="#display">display</a>() slot to another slot as well and
store the value there.
<p> Incidentally, QLCDNumber is the very oldest part of Qt, tracing
back to a BASIC program on the <a href="http://www.nvg.ntnu.no/sinclair/computers/zxspectrum/zxspectrum.htm">Sinclair Spectrum</a>.
<p> <img src=qlcdnum-m.png> <img src=qlcdnum-w.png>
<p> <p>See also <a href="qlabel.html">QLabel</a>, <a href="qframe.html">QFrame</a>, and <a href="basic.html">Basic Widgets</a>.
<hr><h2>Member Type Documentation</h2>
<h3 class=fn><a name="Mode-enum"></a>QLCDNumber::Mode</h3>
<p> This type determines how numbers are shown.
<ul>
<li><tt>QLCDNumber::Hex</tt> - Hexadecimal
<li><tt>QLCDNumber::Dec</tt> - Decimal
<li><tt>QLCDNumber::Oct</tt> - Octal
<li><tt>QLCDNumber::Bin</tt> - Binary
</ul><p> If the display is set to hexadecimal, octal or binary, the integer
equivalent of the value is displayed.
<h3 class=fn><a name="SegmentStyle-enum"></a>QLCDNumber::SegmentStyle</h3>
<p> This type determines the visual appearance of the QLCDNumber
widget.
<ul>
<li><tt>QLCDNumber::Outline</tt> - gives raised segments filled with the background brush.
<li><tt>QLCDNumber::Filled</tt> - gives raised segments filled with the foreground brush.
<li><tt>QLCDNumber::Flat</tt> - gives flat segments filled with the foreground brush.
</ul>
<hr><h2>Member Function Documentation</h2>
<h3 class=fn><a name="QLCDNumber"></a>QLCDNumber::QLCDNumber ( <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0 )
</h3>
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 <a href="#segmentStyle">segmentStyle</a>() is set to <a href="#SegmentStyle-enum">Outline</a>.
<p> The <em>parent</em> and <em>name</em> arguments are passed to the <a href="qframe.html">QFrame</a>
constructor.
<p> <p>See also <a href="#numDigits-prop">numDigits</a> and <a href="#smallDecimalPoint-prop">smallDecimalPoint</a>.
<h3 class=fn><a name="QLCDNumber-2"></a>QLCDNumber::QLCDNumber ( uint&nbsp;numDigits, <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0 )
</h3>
Constructs an LCD number, sets the number of digits to <em>numDigits</em>, the base to decimal, the decimal point mode to 'small'
and the frame style to a raised box. The <a href="#segmentStyle">segmentStyle</a>() is set to
<a href="#SegmentStyle-enum">Outline</a>.
<p> The <em>parent</em> and <em>name</em> arguments are passed to the <a href="qframe.html">QFrame</a>
constructor.
<p> <p>See also <a href="#numDigits-prop">numDigits</a> and <a href="#smallDecimalPoint-prop">smallDecimalPoint</a>.
<h3 class=fn><a name="~QLCDNumber"></a>QLCDNumber::~QLCDNumber ()
</h3>
Destroys the LCD number.
<h3 class=fn>bool <a name="checkOverflow"></a>QLCDNumber::checkOverflow ( double&nbsp;num ) const
</h3>
Returns TRUE if <em>num</em> is too big to be displayed in its entirety;
otherwise returns FALSE.
<p> <p>See also <a href="#display">display</a>(), <a href="#numDigits-prop">numDigits</a>, and <a href="#smallDecimalPoint-prop">smallDecimalPoint</a>.
<h3 class=fn>bool <a name="checkOverflow-2"></a>QLCDNumber::checkOverflow ( int&nbsp;num ) const
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Returns TRUE if <em>num</em> is too big to be displayed in its entirety;
otherwise returns FALSE.
<p> <p>See also <a href="#display">display</a>(), <a href="#numDigits-prop">numDigits</a>, and <a href="#smallDecimalPoint-prop">smallDecimalPoint</a>.
<h3 class=fn>void <a name="display"></a>QLCDNumber::display ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;s )<tt> [slot]</tt>
</h3>
Displays the number represented by the string <em>s</em>.
<p> This version of the function disregards <a href="#mode">mode</a>() and
<a href="#smallDecimalPoint">smallDecimalPoint</a>().
<p> 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.
<p>Examples: <a href="rangecontrols-example.html#x1384">rangecontrols/rangecontrols.cpp</a>, <a href="tutorial1-12.html#x2386">t12/lcdrange.cpp</a>, <a href="tutorial1-13.html#x2414">t13/gamebrd.cpp</a>, <a href="tutorial1-05.html#x2314">t5/main.cpp</a>, <a href="tutorial1-06.html#x2324">t6/main.cpp</a>, <a href="tutorial1-07.html#x2330">t7/lcdrange.cpp</a>, and <a href="xform-example.html#x1229">xform/xform.cpp</a>.
<h3 class=fn>void <a name="display-2"></a>QLCDNumber::display ( int&nbsp;num )<tt> [slot]</tt>
</h3><p>Sets the displayed value rounded to the nearest integer to <em>num</em>.
See the <a href="qlcdnumber.html#intValue-prop">"intValue"</a> property for details.
<h3 class=fn>void <a name="display-3"></a>QLCDNumber::display ( double&nbsp;num )<tt> [slot]</tt>
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Displays the number <em>num</em>.
<h3 class=fn>void <a name="drawContents"></a>QLCDNumber::drawContents ( <a href="qpainter.html">QPainter</a>&nbsp;*&nbsp;p )<tt> [virtual protected]</tt>
</h3>
Draws the LCD number using painter <em>p</em>. This function is called
from <a href="qframe.html#paintEvent">QFrame::paintEvent</a>().
<p>Reimplemented from <a href="qframe.html#drawContents">QFrame</a>.
<h3 class=fn>int <a name="intValue"></a>QLCDNumber::intValue () const
</h3><p>Returns the displayed value rounded to the nearest integer.
See the <a href="qlcdnumber.html#intValue-prop">"intValue"</a> property for details.
<h3 class=fn><a href="qlcdnumber.html#Mode-enum">Mode</a> <a name="mode"></a>QLCDNumber::mode () const
</h3><p>Returns the current display mode (number base).
See the <a href="qlcdnumber.html#mode-prop">"mode"</a> property for details.
<h3 class=fn>int <a name="numDigits"></a>QLCDNumber::numDigits () const
</h3><p>Returns the current number of digits displayed.
See the <a href="qlcdnumber.html#numDigits-prop">"numDigits"</a> property for details.
<h3 class=fn>void <a name="overflow"></a>QLCDNumber::overflow ()<tt> [signal]</tt>
</h3>
<p> This signal is emitted whenever the QLCDNumber is asked to display
a too-large number or a too-long string.
<p> It is never emitted by <a href="#setNumDigits">setNumDigits</a>().
<h3 class=fn><a href="qlcdnumber.html#SegmentStyle-enum">SegmentStyle</a> <a name="segmentStyle"></a>QLCDNumber::segmentStyle () const
</h3><p>Returns the style of the LCDNumber.
See the <a href="qlcdnumber.html#segmentStyle-prop">"segmentStyle"</a> property for details.
<h3 class=fn>void <a name="setBinMode"></a>QLCDNumber::setBinMode ()<tt> [virtual slot]</tt>
</h3>
Calls <a href="#setMode">setMode</a>( BIN ). Provided for convenience (e.g. for
connecting buttons to it).
<p> <p>See also <a href="#mode-prop">mode</a>, <a href="#setHexMode">setHexMode</a>(), <a href="#setDecMode">setDecMode</a>(), <a href="#setOctMode">setOctMode</a>(), and <a href="#mode-prop">mode</a>.
<h3 class=fn>void <a name="setDecMode"></a>QLCDNumber::setDecMode ()<tt> [virtual slot]</tt>
</h3>
Calls <a href="#setMode">setMode</a>( DEC ). Provided for convenience (e.g. for
connecting buttons to it).
<p> <p>See also <a href="#mode-prop">mode</a>, <a href="#setHexMode">setHexMode</a>(), <a href="#setOctMode">setOctMode</a>(), <a href="#setBinMode">setBinMode</a>(), and <a href="#mode-prop">mode</a>.
<h3 class=fn>void <a name="setHexMode"></a>QLCDNumber::setHexMode ()<tt> [virtual slot]</tt>
</h3>
Calls <a href="#setMode">setMode</a>( HEX ). Provided for convenience (e.g. for
connecting buttons to it).
<p> <p>See also <a href="#mode-prop">mode</a>, <a href="#setDecMode">setDecMode</a>(), <a href="#setOctMode">setOctMode</a>(), <a href="#setBinMode">setBinMode</a>(), and <a href="#mode-prop">mode</a>.
<h3 class=fn>void <a name="setMode"></a>QLCDNumber::setMode ( <a href="qlcdnumber.html#Mode-enum">Mode</a> )<tt> [virtual]</tt>
</h3><p>Sets the current display mode (number base).
See the <a href="qlcdnumber.html#mode-prop">"mode"</a> property for details.
<h3 class=fn>void <a name="setNumDigits"></a>QLCDNumber::setNumDigits ( int&nbsp;nDigits )<tt> [virtual]</tt>
</h3><p>Sets the current number of digits displayed to <em>nDigits</em>.
See the <a href="qlcdnumber.html#numDigits-prop">"numDigits"</a> property for details.
<h3 class=fn>void <a name="setOctMode"></a>QLCDNumber::setOctMode ()<tt> [virtual slot]</tt>
</h3>
Calls <a href="#setMode">setMode</a>( OCT ). Provided for convenience (e.g. for
connecting buttons to it).
<p> <p>See also <a href="#mode-prop">mode</a>, <a href="#setHexMode">setHexMode</a>(), <a href="#setDecMode">setDecMode</a>(), <a href="#setBinMode">setBinMode</a>(), and <a href="#mode-prop">mode</a>.
<h3 class=fn>void <a name="setSegmentStyle"></a>QLCDNumber::setSegmentStyle ( <a href="qlcdnumber.html#SegmentStyle-enum">SegmentStyle</a> )<tt> [virtual]</tt>
</h3><p>Sets the style of the LCDNumber.
See the <a href="qlcdnumber.html#segmentStyle-prop">"segmentStyle"</a> property for details.
<h3 class=fn>void <a name="setSmallDecimalPoint"></a>QLCDNumber::setSmallDecimalPoint ( bool )<tt> [virtual slot]</tt>
</h3><p>Sets the style of the decimal point.
See the <a href="qlcdnumber.html#smallDecimalPoint-prop">"smallDecimalPoint"</a> property for details.
<h3 class=fn>bool <a name="smallDecimalPoint"></a>QLCDNumber::smallDecimalPoint () const
</h3><p>Returns the style of the decimal point.
See the <a href="qlcdnumber.html#smallDecimalPoint-prop">"smallDecimalPoint"</a> property for details.
<h3 class=fn>double <a name="value"></a>QLCDNumber::value () const
</h3><p>Returns the displayed value.
See the <a href="qlcdnumber.html#value-prop">"value"</a> property for details.
<hr><h2>Property Documentation</h2>
<h3 class=fn>int <a name="intValue-prop"></a>intValue</h3>
<p>This property holds the displayed value rounded to the nearest integer.
<p>This property corresponds to the nearest integer to the current
value displayed by the LCDNumber. This is the value used for
hexadecimal, octal and binary modes.
<p> If the displayed value is not a number, the property has a value
of 0.
<p>Set this property's value with <a href="#display">display</a>() and get this property's value with <a href="#intValue">intValue</a>().
<h3 class=fn><a href="qlcdnumber.html#Mode-enum">Mode</a> <a name="mode-prop"></a>mode</h3>
<p>This property holds the current display mode (number base).
<p>Corresponds to the current display mode, which is one of <a href="#Mode-enum">BIN</a>,
<a href="#Mode-enum">OCT</a>, <a href="#Mode-enum">DEC</a> (the default) and <a href="#Mode-enum">HEX</a>. <a href="#Mode-enum">DEC</a> mode can display
floating point values, the other modes display the integer
equivalent.
<p> <p>See also <a href="#smallDecimalPoint-prop">smallDecimalPoint</a>, <a href="#setHexMode">setHexMode</a>(), <a href="#setDecMode">setDecMode</a>(), <a href="#setOctMode">setOctMode</a>(), and <a href="#setBinMode">setBinMode</a>().
<p>Set this property's value with <a href="#setMode">setMode</a>() and get this property's value with <a href="#mode">mode</a>().
<h3 class=fn>int <a name="numDigits-prop"></a>numDigits</h3>
<p>This property holds the current number of digits displayed.
<p>Corresponds to the current number of digits. If <a href="#smallDecimalPoint-prop">QLCDNumber::smallDecimalPoint</a> is FALSE, the decimal point occupies
one digit position.
<p> <p>See also <a href="#smallDecimalPoint-prop">smallDecimalPoint</a>.
<p>Set this property's value with <a href="#setNumDigits">setNumDigits</a>() and get this property's value with <a href="#numDigits">numDigits</a>().
<h3 class=fn><a href="qlcdnumber.html#SegmentStyle-enum">SegmentStyle</a> <a name="segmentStyle-prop"></a>segmentStyle</h3>
<p>This property holds the style of the LCDNumber.
<p><center><table cellpadding="4" cellspacing="2" border="0">
<tr bgcolor="#a2c511"> <th valign="top">Style <th valign="top">Result
<tr bgcolor="#f0f0f0"> <td valign="top"><a href="#SegmentStyle-enum">Outline</a>
<td valign="top">Produces raised segments filled with the background color
(this is the default).
<tr bgcolor="#d0d0d0"> <td valign="top"><a href="#SegmentStyle-enum">Filled</a>
<td valign="top">Produces raised segments filled with the foreground color.
<tr bgcolor="#f0f0f0"> <td valign="top"><a href="#SegmentStyle-enum">Flat</a>
<td valign="top">Produces flat segments filled with the foreground color.
</table></center>
<p> <a href="#SegmentStyle-enum">Outline</a> and <a href="#SegmentStyle-enum">Filled</a> will additionally use
<a href="qcolorgroup.html#light">QColorGroup::light</a>() and <a href="qcolorgroup.html#dark">QColorGroup::dark</a>() for shadow effects.
<p>Set this property's value with <a href="#setSegmentStyle">setSegmentStyle</a>() and get this property's value with <a href="#segmentStyle">segmentStyle</a>().
<h3 class=fn>bool <a name="smallDecimalPoint-prop"></a>smallDecimalPoint</h3>
<p>This property holds the style of the decimal point.
<p>If TRUE the decimal point is drawn between two digit positions.
Otherwise it occupies a digit position of its own, i.e. is drawn
in a digit position. The default is FALSE.
<p> The inter-digit space is made slightly wider when the decimal
point is drawn between the digits.
<p> <p>See also <a href="#mode-prop">mode</a>.
<p>Set this property's value with <a href="#setSmallDecimalPoint">setSmallDecimalPoint</a>() and get this property's value with <a href="#smallDecimalPoint">smallDecimalPoint</a>().
<h3 class=fn>double <a name="value-prop"></a>value</h3>
<p>This property holds the displayed value.
<p>This property corresponds to the current value displayed by the
LCDNumber.
<p> If the displayed value is not a number, the property has a value
of 0.
<p>Set this property's value with <a href="#display">display</a>() and get this property's value with <a href="#value">value</a>().
<!-- eof -->
<hr><p>
This file is part of the <a href="index.html">Qt toolkit</a>.
Copyright &copy; 1995-2007
<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
<table width=100% cellspacing=0 border=0><tr>
<td>Copyright &copy; 2007
<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
<td align=right><div align=right>Qt 3.3.8</div>
</table></div></address></body>
</html>