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"><!--
|
---|
8 | fn { margin-left: 1cm; text-indent: -1cm; }
|
---|
9 | a:link { color: #004faf; text-decoration: none }
|
---|
10 | a:visited { color: #672967; text-decoration: none }
|
---|
11 | body { 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 Classes</font></a>
|
---|
23 | | <a href="mainclasses.html">
|
---|
24 | <font color="#004faf">Main 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 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>
|
---|
36 | This examples shows various types of range controls that
|
---|
37 | are 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 <<a href="qvbox-h.html">qvbox.h</a>>
|
---|
54 |
|
---|
55 | class QCheckBox;
|
---|
56 |
|
---|
57 | class RangeControls : public <a href="qvbox.html">QVBox</a>
|
---|
58 | {
|
---|
59 | <a href="metaobjects.html#Q_OBJECT">Q_OBJECT</a>
|
---|
60 |
|
---|
61 | public:
|
---|
62 | RangeControls( <a href="qwidget.html">QWidget</a> *parent = 0, const char *name = 0 );
|
---|
63 |
|
---|
64 | private:
|
---|
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 <<a href="qhbox-h.html">qhbox.h</a>>
|
---|
86 | #include <<a href="qlcdnumber-h.html">qlcdnumber.h</a>>
|
---|
87 | #include <<a href="qspinbox-h.html">qspinbox.h</a>>
|
---|
88 | #include <<a href="qlabel-h.html">qlabel.h</a>>
|
---|
89 | #include <<a href="qstring-h.html">qstring.h</a>>
|
---|
90 | #include <<a href="qslider-h.html">qslider.h</a>>
|
---|
91 | #include <<a href="qcheckbox-h.html">qcheckbox.h</a>>
|
---|
92 |
|
---|
93 | #include <limits.h>
|
---|
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-><a href="qframe.html#setMargin">setMargin</a>( 10 );
|
---|
102 | <a name="x1381"></a> cell2-><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-><a href="qwidget.html#setMaximumHeight">setMaximumHeight</a>( label1-><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-><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-><a href="qwidget.html#setMaximumHeight">setMaximumHeight</a>( label2-><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-><a href="qspinbox.html#setSuffix">setSuffix</a>( " %" );
|
---|
115 | <a name="x1388"></a> sb2-><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-><a href="qwidget.html#setMaximumHeight">setMaximumHeight</a>( label3-><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-><a href="qspinbox.html#setPrefix">setPrefix</a>( "$" );
|
---|
121 | sb3-><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-><a href="qframe.html#setMargin">setMargin</a>( 10 );
|
---|
129 | cell3-><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-><a href="qlcdnumber.html#display">display</a>( 33 );
|
---|
133 | <a name="x1385"></a> lcd2-><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-><a href="qframe.html#setFrameStyle">setFrameStyle</a>( QFrame::WinPanel | QFrame::Sunken );
|
---|
138 | cell4-><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-><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 <<a href="qapplication-h.html">qapplication.h</a>>
|
---|
160 |
|
---|
161 | int 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>( &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 © 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>
|
---|