1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>
Qt Toolkit - rangecontrols/main.cpp example file
</title><style type="text/css"><!--
h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }body { background: white; color: black; }
--></style>
</head><body bgcolor="#ffffff">
<table width="100%">
<tr><td><a href="index.html">
<img width="100" height="100" src="qtlogo.png"
alt="Home" border="0"><img width="100"
height="100" src="face.png" alt="Home" border="0">
</a><td valign=top><div align=right><img src="dochead.png" width="472" height="27"><br>
<a href="classes.html"><b>Classes</b></a>
-<a href="annotated.html">Annotated</a>
- <a href="hierarchy.html">Tree</a>
-<a href="functions.html">Functions</a>
-<a href="index.html">Home</a>
-<a href="topicals.html"><b>Structure</b></a>
</div>
</table>
<h1 align=center>Rangecontrols</h1><br clear="all">
This examples shows the different types of Rangecontrols which
are supported by Qt. These are Dials, Spinboxes and Sliders.
<hr>
Header file: <pre>/****************************************************************************
** $Id: qt/examples/rangecontrols/rangecontrols.h 2.3.2 edited 2001-01-26 $
**
** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
**
** This file is part of an example program for Qt. This example
** program may be used, distributed and modified without limitation.
**
*****************************************************************************/
#ifndef RANGECONTROLS_H
#define RANGECONTROLS_H
#include <<a href="qvbox-h.html">qvbox.h</a>>
class QCheckBox;
class RangeControls : public QVBox
{
Q_OBJECT
public:
RangeControls( <a href="qwidget.html">QWidget</a> *parent = 0, const char *name = 0 );
private:
<a href="qcheckbox.html">QCheckBox</a> *notches, *wrapping;
};
#endif
</pre>
<hr>
Implementation: <pre>/****************************************************************************
** $Id: qt/examples/rangecontrols/rangecontrols.cpp 2.3.2 edited 2001-01-26 $
**
** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
**
** This file is part of an example program for Qt. This example
** program may be used, distributed and modified without limitation.
**
*****************************************************************************/
#include "rangecontrols.h"
#include <<a href="qhbox-h.html">qhbox.h</a>>
#include <<a href="qlcdnumber-h.html">qlcdnumber.h</a>>
#include <<a href="qspinbox-h.html">qspinbox.h</a>>
#include <<a href="qlabel-h.html">qlabel.h</a>>
#include <<a href="qstring-h.html">qstring.h</a>>
#include <<a href="qslider-h.html">qslider.h</a>>
#include <<a href="qcheckbox-h.html">qcheckbox.h</a>>
#include <limits.h>
RangeControls::RangeControls( <a href="qwidget.html">QWidget</a> *parent, const char *name )
: <a href="qvbox.html">QVBox</a>( parent, name )
{
<a href="qhbox.html">QHBox</a> *row1 = new <a href="qhbox.html">QHBox</a>( this );
<a href="qvbox.html">QVBox</a> *cell2 = new <a href="qvbox.html">QVBox</a>( row1 );
cell2-><a href="qframe.html#b11d00">setMargin</a>( 10 );
cell2-><a href="qframe.html#558f79">setFrameStyle</a>( QFrame::WinPanel | QFrame::Sunken );
(void)new <a href="qwidget.html">QWidget</a>( cell2 );
<a href="qlabel.html">QLabel</a> *label1 = new <a href="qlabel.html">QLabel</a>( <a href="qstring.html">QString</a>( "Enter a value between\n%1 and %2:" ).arg( -INT_MAX ).arg( INT_MAX ), cell2 );
label1-><a href="qwidget.html#4e5337">setMaximumHeight</a>( label1-><a href="qlabel.html#f40fcc">sizeHint</a>().height() );
<a href="qspinbox.html">QSpinBox</a> *sb1 = new <a href="qspinbox.html">QSpinBox</a>( -INT_MAX, INT_MAX, 1, cell2 );
sb1-><a href="qspinbox.html#eb409b">setValue</a>( 0 );
<a href="qlabel.html">QLabel</a> *label2 = new <a href="qlabel.html">QLabel</a>( "Enter a zoom value:", cell2 );
label2-><a href="qwidget.html#4e5337">setMaximumHeight</a>( label2-><a href="qlabel.html#f40fcc">sizeHint</a>().height() );
<a href="qspinbox.html">QSpinBox</a> *sb2 = new <a href="qspinbox.html">QSpinBox</a>( 0, 1000, 10, cell2 );
sb2-><a href="qspinbox.html#36bd02">setSuffix</a>( " %" );
sb2-><a href="qspinbox.html#28d1c8">setSpecialValueText</a>( "Automatic" );
<a href="qlabel.html">QLabel</a> *label3 = new <a href="qlabel.html">QLabel</a>( "Enter a price:", cell2 );
label3-><a href="qwidget.html#4e5337">setMaximumHeight</a>( label3-><a href="qlabel.html#f40fcc">sizeHint</a>().height() );
<a href="qspinbox.html">QSpinBox</a> *sb3 = new <a href="qspinbox.html">QSpinBox</a>( 0, INT_MAX, 1, cell2 );
sb3-><a href="qspinbox.html#eccb7d">setPrefix</a>( "$" );
sb3-><a href="qspinbox.html#eb409b">setValue</a>( 355 );
(void)new <a href="qwidget.html">QWidget</a>( cell2 );
<a href="qhbox.html">QHBox</a> *row2 = new <a href="qhbox.html">QHBox</a>( this );
<a href="qvbox.html">QVBox</a> *cell3 = new <a href="qvbox.html">QVBox</a>( row2 );
cell3-><a href="qframe.html#b11d00">setMargin</a>( 10 );
cell3-><a href="qframe.html#558f79">setFrameStyle</a>( QFrame::WinPanel | QFrame::Sunken );
<a href="qslider.html">QSlider</a> *hslider = new <a href="qslider.html">QSlider</a>( 0, 64, 1, 33, Qt::Horizontal, cell3 );
<a href="qlcdnumber.html">QLCDNumber</a> *lcd2 = new <a href="qlcdnumber.html">QLCDNumber</a>( 2, cell3 );
lcd2-><a href="qlcdnumber.html#ecdf88">display</a>( 33 );
lcd2-><a href="qlcdnumber.html#8aa01c">setSegmentStyle</a>( QLCDNumber::Filled );
<a href="qobject.html#7f8e37">connect</a>( hslider, SIGNAL( valueChanged( int ) ), lcd2, SLOT( display( int ) ) );
<a href="qhbox.html">QHBox</a> *cell4 = new <a href="qhbox.html">QHBox</a>( row2 );
cell4-><a href="qframe.html#558f79">setFrameStyle</a>( QFrame::WinPanel | QFrame::Sunken );
cell4-><a href="qframe.html#b11d00">setMargin</a>( 10 );
<a href="qslider.html">QSlider</a> *vslider = new <a href="qslider.html">QSlider</a>( 0, 64, 1, 8, Qt::Vertical, cell4 );
<a href="qlcdnumber.html">QLCDNumber</a> *lcd3 = new <a href="qlcdnumber.html">QLCDNumber</a>( 3, cell4 );
lcd3-><a href="qlcdnumber.html#ecdf88">display</a>( 8 );
<a href="qobject.html#7f8e37">connect</a>( vslider, SIGNAL( valueChanged( int ) ), lcd3, SLOT( display( int ) ) );
}
</pre>
<hr>
Main:
<pre>/****************************************************************************
** $Id: qt/examples/rangecontrols/main.cpp 2.3.2 edited 2001-06-12 $
**
** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
**
** This file is part of an example program for Qt. This example
** program may be used, distributed and modified without limitation.
**
*****************************************************************************/
#include "rangecontrols.h"
#include <<a name="qapplication.h"></a><a href="qapplication-h.html">qapplication.h</a>>
int main( int argc, char **argv )
{
<a name="QApplication"></a><a href="qapplication.html">QApplication</a> a( argc, argv );
RangeControls rangecontrols;
rangecontrols.<a name="resize"></a><a href="qwidget.html#ff9d07">resize</a>( 500, 300 );
rangecontrols.<a name="setCaption"></a><a href="qwidget.html#d6a291">setCaption</a>( "Qt Example - Range Control Widgets" );
a.<a name="setMainWidget"></a><a href="qapplication.html#7ad759">setMainWidget</a>( &rangecontrols );
rangecontrols.<a name="show"></a><a href="qwidget.html#200ee5">show</a>();
return a.<a name="exec"></a><a href="qapplication.html#84c7bf">exec</a>();
}
</pre>
<p><address><hr><div align="center">
<table width="100%" cellspacing="0" border="0"><tr>
<td>Copyright 2001 Trolltech<td><a href="http://www.trolltech.com/trademarks.html">Trademarks</a>
<td align="right"><div align="right">Qt version 2.3.2</div>
</table></div></address></body></html>
|