~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to doc/html/designer-calculatorbuilder-calculatorform-cpp.html

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" encoding="iso-8859-1"?>
 
2
<!DOCTYPE html
 
3
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
 
4
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 
5
<head>
 
6
    <title>Qt 4.0: calculatorform.cpp Example File (designer/calculatorbuilder/calculatorform.cpp)</title>
 
7
    <style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
 
8
a:link { color: #004faf; text-decoration: none }
 
9
a:visited { color: #672967; text-decoration: none }
 
10
td.postheader { font-family: sans-serif }
 
11
tr.address { font-family: sans-serif }
 
12
body { background: #ffffff; color: black; }</style>
 
13
</head>
 
14
<body>
 
15
<table border="0" cellpadding="0" cellspacing="0" width="100%">
 
16
<tr>
 
17
<td align="left" valign="top" width="32"><img src="images/qt-logo.png" align="left" width="32" height="32" border="0" /></td>
 
18
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&nbsp;&middot; <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a>&nbsp;&middot; <a href="mainclasses.html"><font color="#004faf">Main&nbsp;Classes</font></a>&nbsp;&middot; <a href="annotated.html"><font color="#004faf">Annotated</font></a>&nbsp;&middot; <a href="groups.html"><font color="#004faf">Grouped&nbsp;Classes</font></a>&nbsp;&middot; <a href="functions.html"><font color="#004faf">Functions</font></a></td>
 
19
<td align="right" valign="top" width="230"><img src="images/trolltech-logo.png" align="right" width="203" height="32" border="0" /></td></tr></table><h1 align="center">calculatorform.cpp Example File<br /><small><small>designer/calculatorbuilder/calculatorform.cpp</small></small></h1>
 
20
<pre>&nbsp;   #include &lt;QtGui/QtGui&gt;
 
21
    #include &lt;QtDesigner/QFormBuilder&gt;
 
22
 
 
23
    #include &quot;calculatorform.h&quot;
 
24
 
 
25
    CalculatorForm::CalculatorForm(QWidget *parent)
 
26
        : QWidget(parent)
 
27
    {
 
28
        QFormBuilder builder;
 
29
        QFile file(&quot;:/forms/calculatorform.ui&quot;);
 
30
        file.open(QFile::ReadOnly);
 
31
        QWidget *formWidget = builder.load(&amp;file, this);
 
32
        file.close();
 
33
 
 
34
        ui_inputSpinBox1 = qFindChild&lt;QSpinBox*&gt;(this, &quot;inputSpinBox1&quot;);
 
35
        ui_inputSpinBox2 = qFindChild&lt;QSpinBox*&gt;(this, &quot;inputSpinBox2&quot;);
 
36
        ui_outputWidget = qFindChild&lt;QLabel*&gt;(this, &quot;outputWidget&quot;);
 
37
 
 
38
        QMetaObject::connectSlotsByName(this);
 
39
 
 
40
        QVBoxLayout *layout = new QVBoxLayout;
 
41
        layout-&gt;addWidget(formWidget);
 
42
        setLayout(layout);
 
43
 
 
44
        setWindowTitle(tr(&quot;Calculator Builder&quot;));
 
45
    }
 
46
 
 
47
    void CalculatorForm::on_inputSpinBox1_valueChanged(int value)
 
48
    {
 
49
        ui_outputWidget-&gt;setText(QString::number(value + ui_inputSpinBox2-&gt;value()));
 
50
    }
 
51
 
 
52
    void CalculatorForm::on_inputSpinBox2_valueChanged(int value)
 
53
    {
 
54
        ui_outputWidget-&gt;setText(QString::number(value + ui_inputSpinBox1-&gt;value()));
 
55
    }</pre>
 
56
<p /><address><hr /><div align="center">
 
57
<table width="100%" cellspacing="0" border="0"><tr class="address">
 
58
<td width="30%">Copyright &copy; 2005 <a href="trolltech.html">Trolltech</a></td>
 
59
<td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td>
 
60
<td width="30%" align="right"><div align="right">Qt 4.0.0</div></td>
 
61
</tr></table></div></address></body>
 
62
</html>