wizard-example.html

来自「QT 下载资料仅供参考」· HTML 代码 · 共 353 行 · 第 1/2 页

HTML
353
字号
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><!-- /home/reggie/tmp/qt-3.0-reggie-5401/qt-x11-commercial-3.0.5/examples/wizard/wizard.doc:4 --><html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Wizard</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: #ffffff; color: black; }--></style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr bgcolor="#E5E5E5"><td valign=center> <a href="index.html"><font color="#004faf">Home</font></a> | <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a> | <a href="mainclasses.html"><font color="#004faf">Main&nbsp;Classes</font></a> | <a href="annotated.html"><font color="#004faf">Annotated</font></a> | <a href="groups.html"><font color="#004faf">Grouped&nbsp;Classes</font></a> | <a href="functions.html"><font color="#004faf">Functions</font></a></td><td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>Wizard</h1>   <p> This example shows the usage of Qt's wizard class. A wizardshould be used to help a user with complicated actions.<p> <hr><p> Header file:<p> <pre>/****************************************************************************** $Id:  qt/wizard.h   3.0.5   edited Oct 12 2001 $**** 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 WIZARD_H#define WIZARD_H#include &lt;<a href="qwizard-h.html">qwizard.h</a>&gt;class QWidget;class QHBox;class QLineEdit;class QLabel;class Wizard : public <a href="qwizard.html">QWizard</a>{    <a href="metaobjects.html#Q_OBJECT">Q_OBJECT</a>public:    Wizard( <a href="qwidget.html">QWidget</a> *parent = 0, const char *name = 0 );    void showPage(QWidget* page);protected:    void setupPage1();    void setupPage2();    void setupPage3();    <a href="qhbox.html">QHBox</a> *page1, *page2, *page3;    <a href="qlineedit.html">QLineEdit</a> *key, *firstName, *lastName, *address, *phone, *email;    <a href="qlabel.html">QLabel</a> *lKey, *lFirstName, *lLastName, *lAddress, *lPhone, *lEmail;protected slots:    void keyChanged( const <a href="qstring.html">QString</a> &amp; );    void dataChanged( const <a href="qstring.html">QString</a> &amp; );};#endif</pre><p> <hr><p> Implementation:<p> <pre>/****************************************************************************** $Id$**** 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 "wizard.h"#include &lt;<a href="qwidget-h.html">qwidget.h</a>&gt;#include &lt;<a href="qhbox-h.html">qhbox.h</a>&gt;#include &lt;<a href="qvbox-h.html">qvbox.h</a>&gt;#include &lt;<a href="qlabel-h.html">qlabel.h</a>&gt;#include &lt;<a href="qlineedit-h.html">qlineedit.h</a>&gt;#include &lt;<a href="qpushbutton-h.html">qpushbutton.h</a>&gt;#include &lt;<a href="qvalidator-h.html">qvalidator.h</a>&gt;#include &lt;<a href="qapplication-h.html">qapplication.h</a>&gt;<a name="f148"></a>Wizard::Wizard( <a href="qwidget.html">QWidget</a> *parent, const char *name )    : <a href="qwizard.html">QWizard</a>( parent, name, TRUE ){    setupPage1();    setupPage2();    setupPage3();<a name="x11"></a>    key-&gt;<a href="qwidget.html#setFocus">setFocus</a>();}void <a name="f149"></a>Wizard::setupPage1(){    page1 = new <a href="qhbox.html">QHBox</a>( this );<a name="x1"></a>    page1-&gt;<a href="qhbox.html#setSpacing">setSpacing</a>(8);    <a href="qlabel.html">QLabel</a> *info = new <a href="qlabel.html">QLabel</a>( page1 );<a name="x14"></a>    info-&gt;<a href="qwidget.html#setPalette">setPalette</a>( yellow );<a name="x4"></a>    info-&gt;<a href="qlabel.html#setText">setText</a>( "Enter your personal\n"                   "key here.\n\n"                   "Your personal key\n"                   "consists of 4 digits" );<a name="x3"></a>    info-&gt;<a href="qlabel.html#setIndent">setIndent</a>( 8 );<a name="x5"></a><a name="x12"></a>    info-&gt;<a href="qwidget.html#setMaximumWidth">setMaximumWidth</a>( info-&gt;<a href="qwidget.html#sizeHint">sizeHint</a>().width() );    <a href="qvbox.html">QVBox</a> *page = new <a href="qvbox.html">QVBox</a>( page1 );    <a href="qhbox.html">QHBox</a> *row1 = new <a href="qhbox.html">QHBox</a>( page );    (void)new <a href="qlabel.html">QLabel</a>( "Key:", row1 );    key = new <a href="qlineedit.html">QLineEdit</a>( row1 );<a name="x6"></a>    key-&gt;<a href="qlineedit.html#setMaxLength">setMaxLength</a>( 4 );<a name="x7"></a>    key-&gt;<a href="qlineedit.html#setValidator">setValidator</a>( new <a href="qintvalidator.html">QIntValidator</a>( 1000, 9999, key ) );<a name="x9"></a>    <a href="qobject.html#connect">connect</a>( key, SIGNAL( <a href="qlineedit.html#textChanged">textChanged</a>( const <a href="qstring.html">QString</a> &amp; ) ),             this, SLOT( keyChanged( const <a href="qstring.html">QString</a> &amp; ) ) );    <a href="qwizard.html#addPage">addPage</a>( page1, "Personal Key" );    <a href="qwizard.html#setNextEnabled">setNextEnabled</a>( page1, FALSE );    <a href="qwizard.html#setHelpEnabled">setHelpEnabled</a>( page1, FALSE );}void <a name="f150"></a>Wizard::setupPage2(){    page2 = new <a href="qhbox.html">QHBox</a>( this );    page2-&gt;<a href="qhbox.html#setSpacing">setSpacing</a>(8);    <a href="qlabel.html">QLabel</a> *info = new <a href="qlabel.html">QLabel</a>( page2 );    info-&gt;<a href="qwidget.html#setPalette">setPalette</a>( yellow );    info-&gt;<a href="qlabel.html#setText">setText</a>( "\n"                   "  Enter your personal  \n"                   "  data here.  \n\n"                   "  The required fields are  \n"                   "  First Name, Last Name \n"                   "  and E-Mail.  \n" );    info-&gt;<a href="qlabel.html#setIndent">setIndent</a>(8);    info-&gt;<a href="qwidget.html#setMaximumWidth">setMaximumWidth</a>( info-&gt;<a href="qwidget.html#sizeHint">sizeHint</a>().width() );    <a href="qvbox.html">QVBox</a> *page = new <a href="qvbox.html">QVBox</a>( page2 );    <a href="qhbox.html">QHBox</a> *row1 = new <a href="qhbox.html">QHBox</a>( page );    <a href="qhbox.html">QHBox</a> *row2 = new <a href="qhbox.html">QHBox</a>( page );    <a href="qhbox.html">QHBox</a> *row3 = new <a href="qhbox.html">QHBox</a>( page );    <a href="qhbox.html">QHBox</a> *row4 = new <a href="qhbox.html">QHBox</a>( page );    <a href="qhbox.html">QHBox</a> *row5 = new <a href="qhbox.html">QHBox</a>( page );    <a href="qlabel.html">QLabel</a> *label1 = new <a href="qlabel.html">QLabel</a>( " First Name: ", row1 );

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?