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

« back to all changes in this revision

Viewing changes to doc/html/tutorials-widgets-childwidget.html

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghersi
  • Date: 2009-11-02 18:30:08 UTC
  • mfrom: (1.2.2 upstream)
  • mto: (15.2.5 experimental)
  • mto: This revision was merged to the branch mainline in revision 88.
  • Revision ID: james.westby@ubuntu.com-20091102183008-b6a4gcs128mvfb3m
Tags: upstream-4.6.0~beta1
ImportĀ upstreamĀ versionĀ 4.6.0~beta1

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
<!-- widgets-tutorial.qdoc -->
 
6
<head>
 
7
  <title>Qt 4.6: Widgets Tutorial - Child Widgets</title>
 
8
  <link rel="prev" href="tutorials-widgets-toplevel.html" />
 
9
  <link rel="contents" href="widgets-tutorial.html" />
 
10
  <link rel="next" href="tutorials-widgets-windowlayout.html" />
 
11
  <link href="classic.css" rel="stylesheet" type="text/css" />
 
12
</head>
 
13
<body>
 
14
<table border="0" cellpadding="0" cellspacing="0" width="100%">
 
15
<tr>
 
16
<td align="left" valign="top" width="32"><a href="http://qt.nokia.com/"><img src="images/qt-logo.png" align="left" border="0" /></a></td>
 
17
<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="functions.html"><font color="#004faf">All&nbsp;Functions</font></a>&nbsp;&middot; <a href="overviews.html"><font color="#004faf">Overviews</font></a></td><td class="searchBar" align="right" valign="center"><form action="http://www.google.com/cse" id="cse-search-box"><div><input type="hidden" name="cx" value="000136343326384750312:dhbxnqlakyu" /><input type="hidden" name="ie" value="UTF-8" /><input type="text" name="q" size="31" /><input type="submit" name="sa" value="Search" /></div></form></td>
 
18
</tr></table><p>
 
19
[Previous: <a href="tutorials-widgets-toplevel.html">Widgets Tutorial - Creating a Window</a>]
 
20
[<a href="widgets-tutorial.html">Contents</a>]
 
21
[Next: <a href="tutorials-widgets-windowlayout.html">Widgets Tutorial - Using Layouts</a>]
 
22
</p>
 
23
<h1 class="title">Widgets Tutorial - Child Widgets<br /><span class="subtitle"></span>
 
24
</h1>
 
25
<p>Files:</p>
 
26
<ul>
 
27
<li><a href="tutorials-widgets-childwidget-main-cpp.html">tutorials/widgets/childwidget/main.cpp</a></li>
 
28
<li><a href="tutorials-widgets-childwidget-childwidget-pro.html">tutorials/widgets/childwidget/childwidget.pro</a></li>
 
29
</ul>
 
30
<p>We can add a child widget to the window created in the previous example by passing <tt>window</tt> as the parent to its constructor. In this case, we add a button to the window and place it in a specific location:</p>
 
31
    <table align="left" width="100%">
 
32
    <tr class="qt-code"><td>
 
33
    <pre> #include &lt;QtGui&gt;
 
34
 
 
35
 int main(int argc, char *argv[])
 
36
 {
 
37
     QApplication app(argc, argv);
 
38
     QWidget window;
 
39
     window.resize(320, 240);
 
40
     window.setWindowTitle(QApplication::translate(&quot;childwidget&quot;, &quot;Child widget&quot;));
 
41
     window.show();
 
42
 
 
43
     QPushButton *button = new QPushButton(
 
44
         QApplication::translate(&quot;childwidget&quot;, &quot;Press me&quot;), &amp;window);
 
45
     button-&gt;move(100, 100);
 
46
     button-&gt;show();
 
47
     return app.exec();
 
48
 }</pre>
 
49
    </td><td align="right">
 
50
    <p><img src="images/widgets-tutorial-childwidget.png" /></p>
 
51
    </td></tr>
 
52
    </table>
 
53
    <p>The button is now a child of the window and will be deleted when the window is destroyed. Note that hiding or closing the window does not automatically destroy it. It will be destroyed when the example exits.</p>
 
54
<p>
 
55
[Previous: <a href="tutorials-widgets-toplevel.html">Widgets Tutorial - Creating a Window</a>]
 
56
[<a href="widgets-tutorial.html">Contents</a>]
 
57
[Next: <a href="tutorials-widgets-windowlayout.html">Widgets Tutorial - Using Layouts</a>]
 
58
</p>
 
59
<p /><address><hr /><div align="center">
 
60
<table width="100%" cellspacing="0" border="0"><tr class="address">
 
61
<td width="40%" align="left">Copyright &copy; 2009 Nokia Corporation and/or its subsidiary(-ies)</td>
 
62
<td width="20%" align="center"><a href="trademarks.html">Trademarks</a></td>
 
63
<td width="40%" align="right"><div align="right">Qt 4.6.0</div></td>
 
64
<script type="text/javascript" src="http://www.google.com/jsapi"></script><script type="text/javascript">google.load("elements", "1", {packages: "transliteration"});</script><script type="text/javascript" src="http://www.google.com/coop/cse/t13n?form=cse-search-box&t13n_langs=en"></script><script type="text/javascript" src="http://www.google.com/coop/cse/brand?form=cse-search-box&lang=en"></script></tr></table></div></address></body>
 
65
</html>