source: trunk/doc/html/chart-optionsform-cpp.html

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

reference documentation added

File size: 9.9 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/doc/tutorial2.doc:13 -->
3<html>
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
6<title>chart/optionsform.cpp Example File</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>chart/optionsform.cpp Example File</h1>
33
34
35<pre>#include "optionsform.h"
36
37#include &lt;<a href="qbuttongroup-h.html">qbuttongroup.h</a>&gt;
38#include &lt;<a href="qcombobox-h.html">qcombobox.h</a>&gt;
39#include &lt;<a href="qfontdialog-h.html">qfontdialog.h</a>&gt;
40#include &lt;<a href="qframe-h.html">qframe.h</a>&gt;
41#include &lt;<a href="qimage-h.html">qimage.h</a>&gt;
42#include &lt;<a href="qlabel-h.html">qlabel.h</a>&gt;
43#include &lt;<a href="qlayout-h.html">qlayout.h</a>&gt;
44#include &lt;<a href="qpushbutton-h.html">qpushbutton.h</a>&gt;
45#include &lt;<a href="qradiobutton-h.html">qradiobutton.h</a>&gt;
46#include &lt;<a href="qspinbox-h.html">qspinbox.h</a>&gt;
47
48#include "images/options_horizontalbarchart.xpm"
49#include "images/options_piechart.xpm"
50#include "images/options_verticalbarchart.xpm"
51
52
53<a name="f176"></a>OptionsForm::OptionsForm( <a href="qwidget.html">QWidget</a>* parent, const char* name,
54 bool modal, WFlags f )
55 : <a href="qdialog.html">QDialog</a>( parent, name, modal, f )
56{
57 <a href="qwidget.html#setCaption">setCaption</a>( "Chart -- Options" );
58 <a href="qwidget.html#resize">resize</a>( 320, 290 );
59
60 optionsFormLayout = new <a href="qvboxlayout.html">QVBoxLayout</a>( this, 11, 6 );
61
62 chartTypeLayout = new <a href="qhboxlayout.html">QHBoxLayout</a>( 0, 0, 6 );
63
64 chartTypeTextLabel = new <a href="qlabel.html">QLabel</a>( "&amp;Chart Type", this );
65 chartTypeLayout-&gt;<a href="qboxlayout.html#addWidget">addWidget</a>( chartTypeTextLabel );
66
67 chartTypeComboBox = new <a href="qcombobox.html">QComboBox</a>( FALSE, this );
68 chartTypeComboBox-&gt;<a href="qcombobox.html#insertItem">insertItem</a>( QPixmap( options_piechart ), "Pie Chart" );
69 chartTypeComboBox-&gt;<a href="qcombobox.html#insertItem">insertItem</a>( QPixmap( options_verticalbarchart ),
70 "Vertical Bar Chart" );
71 chartTypeComboBox-&gt;<a href="qcombobox.html#insertItem">insertItem</a>( QPixmap( options_horizontalbarchart ),
72 "Horizontal Bar Chart" );
73 chartTypeLayout-&gt;<a href="qboxlayout.html#addWidget">addWidget</a>( chartTypeComboBox );
74 optionsFormLayout-&gt;<a href="qboxlayout.html#addLayout">addLayout</a>( chartTypeLayout );
75
76 fontLayout = new <a href="qhboxlayout.html">QHBoxLayout</a>( 0, 0, 6 );
77
78 fontPushButton = new <a href="qpushbutton.html">QPushButton</a>( "&amp;Font...", this );
79 fontLayout-&gt;<a href="qboxlayout.html#addWidget">addWidget</a>( fontPushButton );
80 <a href="qspaceritem.html">QSpacerItem</a>* spacer = new <a href="qspaceritem.html">QSpacerItem</a>( 0, 0,
81 QSizePolicy::Expanding,
82 QSizePolicy::Minimum );
83 fontLayout-&gt;<a href="qboxlayout.html#addItem">addItem</a>( spacer );
84
85 fontTextLabel = new <a href="qlabel.html">QLabel</a>( this ); // Must be set by caller via setFont()
86 fontLayout-&gt;<a href="qboxlayout.html#addWidget">addWidget</a>( fontTextLabel );
87 optionsFormLayout-&gt;<a href="qboxlayout.html#addLayout">addLayout</a>( fontLayout );
88
89 addValuesFrame = new <a href="qframe.html">QFrame</a>( this );
90 addValuesFrame-&gt;<a href="qframe.html#setFrameShape">setFrameShape</a>( QFrame::StyledPanel );
91 addValuesFrame-&gt;<a href="qframe.html#setFrameShadow">setFrameShadow</a>( QFrame::Sunken );
92 addValuesFrameLayout = new <a href="qvboxlayout.html">QVBoxLayout</a>( addValuesFrame, 11, 6 );
93
94 addValuesButtonGroup = new <a href="qbuttongroup.html">QButtonGroup</a>( "Show Values", addValuesFrame );
95 addValuesButtonGroup-&gt;<a href="qgroupbox.html#setColumnLayout">setColumnLayout</a>(0, Qt::Vertical );
96 addValuesButtonGroup-&gt;<a href="qwidget.html#layout">layout</a>()-&gt;setSpacing( 6 );
97 addValuesButtonGroup-&gt;<a href="qwidget.html#layout">layout</a>()-&gt;setMargin( 11 );
98 addValuesButtonGroupLayout = new <a href="qvboxlayout.html">QVBoxLayout</a>(
99 addValuesButtonGroup-&gt;<a href="qwidget.html#layout">layout</a>() );
100 addValuesButtonGroupLayout-&gt;<a href="qlayoutitem.html#setAlignment">setAlignment</a>( Qt::AlignTop );
101
102 noRadioButton = new <a href="qradiobutton.html">QRadioButton</a>( "&amp;No", addValuesButtonGroup );
103 noRadioButton-&gt;<a href="qradiobutton.html#setChecked">setChecked</a>( TRUE );
104 addValuesButtonGroupLayout-&gt;<a href="qboxlayout.html#addWidget">addWidget</a>( noRadioButton );
105
106 yesRadioButton = new <a href="qradiobutton.html">QRadioButton</a>( "&amp;Yes", addValuesButtonGroup );
107 addValuesButtonGroupLayout-&gt;<a href="qboxlayout.html#addWidget">addWidget</a>( yesRadioButton );
108
109 asPercentageRadioButton = new <a href="qradiobutton.html">QRadioButton</a>( "As &amp;Percentage",
110 addValuesButtonGroup );
111 addValuesButtonGroupLayout-&gt;<a href="qboxlayout.html#addWidget">addWidget</a>( asPercentageRadioButton );
112 addValuesFrameLayout-&gt;<a href="qboxlayout.html#addWidget">addWidget</a>( addValuesButtonGroup );
113
114 decimalPlacesLayout = new <a href="qhboxlayout.html">QHBoxLayout</a>( 0, 0, 6 );
115
116 decimalPlacesTextLabel = new <a href="qlabel.html">QLabel</a>( "&amp;Decimal Places", addValuesFrame );
117 decimalPlacesLayout-&gt;<a href="qboxlayout.html#addWidget">addWidget</a>( decimalPlacesTextLabel );
118
119 decimalPlacesSpinBox = new <a href="qspinbox.html">QSpinBox</a>( addValuesFrame );
120 decimalPlacesSpinBox-&gt;<a href="qspinbox.html#setMinValue">setMinValue</a>( 0 );
121 decimalPlacesSpinBox-&gt;<a href="qspinbox.html#setMaxValue">setMaxValue</a>( 9 );
122 decimalPlacesLayout-&gt;<a href="qboxlayout.html#addWidget">addWidget</a>( decimalPlacesSpinBox );
123
124 addValuesFrameLayout-&gt;<a href="qboxlayout.html#addLayout">addLayout</a>( decimalPlacesLayout );
125
126 optionsFormLayout-&gt;<a href="qboxlayout.html#addWidget">addWidget</a>( addValuesFrame );
127
128 buttonsLayout = new <a href="qhboxlayout.html">QHBoxLayout</a>( 0, 0, 6 );
129 spacer = new <a href="qspaceritem.html">QSpacerItem</a>( 0, 0,
130 QSizePolicy::Expanding, QSizePolicy::Minimum );
131 buttonsLayout-&gt;<a href="qboxlayout.html#addItem">addItem</a>( spacer );
132
133 okPushButton = new <a href="qpushbutton.html">QPushButton</a>( "OK", this );
134 okPushButton-&gt;<a href="qpushbutton.html#setDefault">setDefault</a>( TRUE );
135 buttonsLayout-&gt;<a href="qboxlayout.html#addWidget">addWidget</a>( okPushButton );
136
137 cancelPushButton = new <a href="qpushbutton.html">QPushButton</a>( "Cancel", this );
138 buttonsLayout-&gt;<a href="qboxlayout.html#addWidget">addWidget</a>( cancelPushButton );
139 optionsFormLayout-&gt;<a href="qboxlayout.html#addLayout">addLayout</a>( buttonsLayout );
140
141 <a href="qobject.html#connect">connect</a>( fontPushButton, SIGNAL( <a href="qbutton.html#clicked">clicked</a>() ), this, SLOT( chooseFont() ) );
142 <a href="qobject.html#connect">connect</a>( okPushButton, SIGNAL( <a href="qbutton.html#clicked">clicked</a>() ), this, SLOT( <a href="qdialog.html#accept">accept</a>() ) );
143 <a href="qobject.html#connect">connect</a>( cancelPushButton, SIGNAL( <a href="qbutton.html#clicked">clicked</a>() ), this, SLOT( <a href="qdialog.html#reject">reject</a>() ) );
144
145 chartTypeTextLabel-&gt;<a href="qlabel.html#setBuddy">setBuddy</a>( chartTypeComboBox );
146 decimalPlacesTextLabel-&gt;<a href="qlabel.html#setBuddy">setBuddy</a>( decimalPlacesSpinBox );
147}
148
149
150void <a name="f177"></a>OptionsForm::chooseFont()
151{
152 bool ok;
153 <a href="qfont.html">QFont</a> font = QFontDialog::<a href="qfontdialog.html#getFont">getFont</a>( &amp;ok, m_font, this );
154 if ( ok )
155 <a href="qwidget.html#setFont">setFont</a>( font );
156}
157
158
159void OptionsForm::<a href="qwidget.html#setFont">setFont</a>( <a href="qfont.html">QFont</a> font )
160{
161 <a href="qstring.html">QString</a> label = font.<a href="qfont.html#family">family</a>() + " " +
162 QString::<a href="qstring.html#number">number</a>( font.<a href="qfont.html#pointSize">pointSize</a>() ) + "pt";
163 if ( font.<a href="qfont.html#bold">bold</a>() )
164 label += " Bold";
165 if ( font.<a href="qfont.html#italic">italic</a>() )
166 label += " Italic";
167 fontTextLabel-&gt;<a href="qlabel.html#setText">setText</a>( label );
168 m_font = font;
169}
170</pre><!-- eof -->
171<p><address><hr><div align=center>
172<table width=100% cellspacing=0 border=0><tr>
173<td>Copyright &copy; 2007
174<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
175<td align=right><div align=right>Qt 3.3.8</div>
176</table></div></address></body>
177</html>
Note: See TracBrowser for help on using the repository browser.