⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 t3.html

📁 qtopiaphone英文帮助,用于初学者和开发人员,初学者可以用来学习,开发人员可以用来资料查询.
💻 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 Tutorial - Chapter 3: Family Values</title></head><body bgcolor="#ffffff"><p><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><p><h1 align=center>Chapter 3: Family Values</h1><br clear="all"><p><center><img src="t3.png" alt="Screenshot of tutorial three"></center><p>This example shows how to create mother and child widgets.<p>We'll keep it simple and use just a single mother (uh, family values?)and a lone child. <pre>/******************************************************************** Qt tutorial 3******************************************************************/#include &lt;<a href="qapplication-h.html">qapplication.h</a>&gt;#include &lt;<a href="qpushbutton-h.html">qpushbutton.h</a>&gt;#include &lt;<a href="qfont-h.html">qfont.h</a>&gt;#include &lt;<a href="qvbox-h.html">qvbox.h</a>&gt;int main( int argc, char **argv ){    <a href="qapplication.html">QApplication</a> a( argc, argv );    <a href="qvbox.html">QVBox</a> box;    box.<a href="qwidget.html#ff9d07">resize</a>( 200, 120 );    <a href="qpushbutton.html">QPushButton</a> quit( "Quit", &amp;box );    quit.<a href="qwidget.html#090d60">setFont</a>( <a href="qfont.html">QFont</a>( "Times", 18, QFont::Bold ) );    <a href="qobject.html#7f8e37">QObject::connect</a>( &amp;quit, SIGNAL(clicked()), &amp;a, SLOT(quit()) );    a.<a href="qapplication.html#7ad759">setMainWidget</a>( &amp;box );    box.<a href="qwidget.html#200ee5">show</a>();    return a.<a href="qapplication.html#84c7bf">exec</a>();}</pre><p><h2>Line by Line Walk-Through</h2>  <pre>    #include &lt;<a href="qvbox-h.html">qvbox.h</a>&gt;</pre><p>We add an include of qvbox.h, to get the layout class we'll use.  <pre>        <a href="qvbox.html">QVBox</a> box;</pre><p>Here we simply create a vertical box container.  The QVBox arrangesits child widgets in a vertical row, one above the other, handing outspace according to each child's <a href="qwidget.html#23726d">QWidget::sizePolicy()</a>. <pre>        box.<a href="qwidget.html#ff9d07">resize</a>( 200, 120 );</pre><p>We set its width to 200 pixels and the height to 120 pixels. <pre>        <a href="qpushbutton.html">QPushButton</a> quit( "Quit", &amp;box );</pre><p>A child is born.<p>This QPushButton is created with both a text, "Quit", and a mother,box.  A child widget is always on top of its mother.  When displayed,it is clipped by its mother's bounds.<p>The mother widget, the QVBox, automatically adds the child, centeredin its box.  Since nothing else is added, the button gets all thespace the mother has.  <pre>        box.<a href="qwidget.html#200ee5">show</a>();</pre><p>When a mother widget is shown, it will call show for all its children(except those on which you have done an explicit <a href="qwidget.html#410481">QWidget::hide())</a>.<p><h2>Behavior</h2><p>The button no longer fills the entire widget.  Instead, it gets a"natural" size.  This is because there is now a new top-level widget,which uses layout management to set a good size and position for thebutton.<p><h2>Exercises</h2><p>Try resizing the window.  How does the button change?  What is thebutton's size change policy?  What happens if you try to make thewindow <em>really</em> small?<p>You may now go on to <a href="t4.html">chapter four.</a><p>[<a href="t2.html">Previous tutorial</a>][<a href="t4.html">Next tutorial</a>][<a href="tutorial.html">Main tutorial page</a>]<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 + -