source: trunk/doc/html/rangecontrols-example.html@ 190

Last change on this file since 190 was 190, checked in by rudi, 14 years ago

reference documentation added

File size: 8.8 KB
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/examples/rangecontrols/rangecontrols.doc:4 -->
3<html>
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
6<title>Range controls</title>
7<style type="text/css"><!--
8fn { margin-left: 1cm; text-indent: -1cm; }
9a:link { color: #004faf; text-decoration: none }
10a:visited { color: #672967; text-decoration: none }
11body { background: #ffffff; color: black; }
12--></style>
13</head>
14<body>
15
16<table border="0" cellpadding="0" cellspacing="0" width="100%">
17<tr bgcolor="#E5E5E5">
18<td valign=center>
19 <a href="index.html">
20<font color="#004faf">Home</font></a>
21 | <a href="classes.html">
22<font color="#004faf">All&nbsp;Classes</font></a>
23 | <a href="mainclasses.html">
24<font color="#004faf">Main&nbsp;Classes</font></a>
25 | <a href="annotated.html">
26<font color="#004faf">Annotated</font></a>
27 | <a href="groups.html">
28<font color="#004faf">Grouped&nbsp;Classes</font></a>
29 | <a href="functions.html">
30<font color="#004faf">Functions</font></a>
31</td>
32<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>Range controls</h1>
33
34
35<p>
36This examples shows various types of range controls that
37are supported by Qt: dials, spin boxes and sliders.
38<p> <hr>
39<p> Header file:
40<p> <pre>/****************************************************************************
41** $Id: rangecontrols-example.html 2051 2007-02-21 10:04:20Z chehrlic $
42**
43** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved.
44**
45** This file is part of an example program for Qt. This example
46** program may be used, distributed and modified without limitation.
47**
48*****************************************************************************/
49
50#ifndef RANGECONTROLS_H
51#define RANGECONTROLS_H
52
53#include &lt;<a href="qvbox-h.html">qvbox.h</a>&gt;
54
55class QCheckBox;
56
57class RangeControls : public <a href="qvbox.html">QVBox</a>
58{
59 <a href="metaobjects.html#Q_OBJECT">Q_OBJECT</a>
60
61public:
62 RangeControls( <a href="qwidget.html">QWidget</a> *parent = 0, const char *name = 0 );
63
64private:
65 <a href="qcheckbox.html">QCheckBox</a> *notches, *wrapping;
66};
67
68#endif
69</pre>
70
71<p> <hr>
72<p> Implementation:
73<p> <pre>/****************************************************************************
74** $Id: rangecontrols-example.html 2051 2007-02-21 10:04:20Z chehrlic $
75**
76** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved.
77**
78** This file is part of an example program for Qt. This example
79** program may be used, distributed and modified without limitation.
80**
81*****************************************************************************/
82
83#include "rangecontrols.h"
84
85#include &lt;<a href="qhbox-h.html">qhbox.h</a>&gt;
86#include &lt;<a href="qlcdnumber-h.html">qlcdnumber.h</a>&gt;
87#include &lt;<a href="qspinbox-h.html">qspinbox.h</a>&gt;
88#include &lt;<a href="qlabel-h.html">qlabel.h</a>&gt;
89#include &lt;<a href="qstring-h.html">qstring.h</a>&gt;
90#include &lt;<a href="qslider-h.html">qslider.h</a>&gt;
91#include &lt;<a href="qcheckbox-h.html">qcheckbox.h</a>&gt;
92
93#include &lt;limits.h&gt;
94
95<a name="f436"></a>RangeControls::RangeControls( <a href="qwidget.html">QWidget</a> *parent, const char *name )
96 : <a href="qvbox.html">QVBox</a>( parent, name )
97{
98 <a href="qhbox.html">QHBox</a> *row1 = new <a href="qhbox.html">QHBox</a>( this );
99
100 <a href="qvbox.html">QVBox</a> *cell2 = new <a href="qvbox.html">QVBox</a>( row1 );
101<a name="x1382"></a> cell2-&gt;<a href="qframe.html#setMargin">setMargin</a>( 10 );
102<a name="x1381"></a> cell2-&gt;<a href="qframe.html#setFrameStyle">setFrameStyle</a>( QFrame::WinPanel | QFrame::Sunken );
103
104 (void)new <a href="qwidget.html">QWidget</a>( cell2 );
105
106 <a href="qlabel.html">QLabel</a> *label1 = new <a href="qlabel.html">QLabel</a>( QString( "Enter a value between\n%1 and %2:" ).arg( -INT_MAX ).arg( INT_MAX ), cell2 );
107<a name="x1391"></a><a name="x1383"></a> label1-&gt;<a href="qwidget.html#setMaximumHeight">setMaximumHeight</a>( label1-&gt;<a href="qwidget.html#sizeHint">sizeHint</a>().height() );
108 <a href="qspinbox.html">QSpinBox</a> *sb1 = new <a href="qspinbox.html">QSpinBox</a>( -INT_MAX, INT_MAX, 1, cell2 );
109<a name="x1390"></a> sb1-&gt;<a href="qspinbox.html#setValue">setValue</a>( 0 );
110
111 <a href="qlabel.html">QLabel</a> *label2 = new <a href="qlabel.html">QLabel</a>( "Enter a zoom value:", cell2 );
112 label2-&gt;<a href="qwidget.html#setMaximumHeight">setMaximumHeight</a>( label2-&gt;<a href="qwidget.html#sizeHint">sizeHint</a>().height() );
113 <a href="qspinbox.html">QSpinBox</a> *sb2 = new <a href="qspinbox.html">QSpinBox</a>( 0, 1000, 10, cell2 );
114<a name="x1389"></a> sb2-&gt;<a href="qspinbox.html#setSuffix">setSuffix</a>( " %" );
115<a name="x1388"></a> sb2-&gt;<a href="qspinbox.html#setSpecialValueText">setSpecialValueText</a>( "Automatic" );
116
117 <a href="qlabel.html">QLabel</a> *label3 = new <a href="qlabel.html">QLabel</a>( "Enter a price:", cell2 );
118 label3-&gt;<a href="qwidget.html#setMaximumHeight">setMaximumHeight</a>( label3-&gt;<a href="qwidget.html#sizeHint">sizeHint</a>().height() );
119 <a href="qspinbox.html">QSpinBox</a> *sb3 = new <a href="qspinbox.html">QSpinBox</a>( 0, INT_MAX, 1, cell2 );
120<a name="x1387"></a> sb3-&gt;<a href="qspinbox.html#setPrefix">setPrefix</a>( "$" );
121 sb3-&gt;<a href="qspinbox.html#setValue">setValue</a>( 355 );
122
123 (void)new <a href="qwidget.html">QWidget</a>( cell2 );
124
125 <a href="qhbox.html">QHBox</a> *row2 = new <a href="qhbox.html">QHBox</a>( this );
126
127 <a href="qvbox.html">QVBox</a> *cell3 = new <a href="qvbox.html">QVBox</a>( row2 );
128 cell3-&gt;<a href="qframe.html#setMargin">setMargin</a>( 10 );
129 cell3-&gt;<a href="qframe.html#setFrameStyle">setFrameStyle</a>( QFrame::WinPanel | QFrame::Sunken );
130 <a href="qslider.html">QSlider</a> *hslider = new <a href="qslider.html">QSlider</a>( 0, 64, 1, 33, Qt::Horizontal, cell3, "horizontal_s" );
131 <a href="qlcdnumber.html">QLCDNumber</a> *lcd2 = new <a href="qlcdnumber.html">QLCDNumber</a>( 2, cell3 );
132<a name="x1384"></a> lcd2-&gt;<a href="qlcdnumber.html#display">display</a>( 33 );
133<a name="x1385"></a> lcd2-&gt;<a href="qlcdnumber.html#setSegmentStyle">setSegmentStyle</a>( QLCDNumber::Filled );
134<a name="x1386"></a> <a href="qobject.html#connect">connect</a>( hslider, SIGNAL( <a href="qslider.html#valueChanged">valueChanged</a>( int ) ), lcd2, SLOT( <a href="qlcdnumber.html#display">display</a>( int ) ) );
135
136 <a href="qhbox.html">QHBox</a> *cell4 = new <a href="qhbox.html">QHBox</a>( row2 );
137 cell4-&gt;<a href="qframe.html#setFrameStyle">setFrameStyle</a>( QFrame::WinPanel | QFrame::Sunken );
138 cell4-&gt;<a href="qframe.html#setMargin">setMargin</a>( 10 );
139 <a href="qslider.html">QSlider</a> *vslider = new <a href="qslider.html">QSlider</a>( 0, 64, 1, 8, Qt::Vertical, cell4 );
140 <a href="qlcdnumber.html">QLCDNumber</a> *lcd3 = new <a href="qlcdnumber.html">QLCDNumber</a>( 3, cell4 );
141 lcd3-&gt;<a href="qlcdnumber.html#display">display</a>( 8 );
142 <a href="qobject.html#connect">connect</a>( vslider, SIGNAL( <a href="qslider.html#valueChanged">valueChanged</a>( int ) ), lcd3, SLOT( <a href="qlcdnumber.html#display">display</a>( int ) ) );
143}
144</pre>
145
146<p> <hr>
147<p> Main:
148<p> <pre>/****************************************************************************
149** $Id: rangecontrols-example.html 2051 2007-02-21 10:04:20Z chehrlic $
150**
151** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved.
152**
153** This file is part of an example program for Qt. This example
154** program may be used, distributed and modified without limitation.
155**
156*****************************************************************************/
157
158#include "rangecontrols.h"
159#include &lt;<a href="qapplication-h.html">qapplication.h</a>&gt;
160
161int main( int argc, char **argv )
162{
163 <a href="qapplication.html">QApplication</a> a( argc, argv );
164
165 RangeControls rangecontrols;
166 rangecontrols.<a href="qwidget.html#resize">resize</a>( 500, 300 );
167 rangecontrols.<a href="qwidget.html#setCaption">setCaption</a>( "Qt Example - Range Control Widgets" );
168 a.<a href="qapplication.html#setMainWidget">setMainWidget</a>( &amp;rangecontrols );
169 rangecontrols.<a href="qwidget.html#show">show</a>();
170
171 return a.<a href="qapplication.html#exec">exec</a>();
172}
173</pre>
174
175<p>See also <a href="examples.html">Examples</a>.
176
177<!-- eof -->
178<p><address><hr><div align=center>
179<table width=100% cellspacing=0 border=0><tr>
180<td>Copyright &copy; 2007
181<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
182<td align=right><div align=right>Qt 3.3.8</div>
183</table></div></address></body>
184</html>
Note: See TracBrowser for help on using the repository browser.