📄 rangecontrols-main-cpp.html
字号:
<!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> <font face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular" align="center" size=32>Qte</font></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.8 edited 2004-05-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.*******************************************************************************/#ifndef RANGECONTROLS_H#define RANGECONTROLS_H#include <<a href="qvbox-h.html">qvbox.h</a>>class QCheckBox;class RangeControls : public QVBox{ Q_OBJECTpublic: 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.8 edited 2004-05-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 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#fbde73">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#fbde73">connect</a>( vslider, SIGNAL( valueChanged( int ) ), lcd3, SLOT( display( int ) ) );}</pre> <hr> Main:<pre>/****************************************************************************** $Id: qt/examples/rangecontrols/main.cpp 2.3.8 edited 2004-05-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
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -