diff options
author | Timothy Pearson <[email protected]> | 2011-11-08 12:31:36 -0600 |
---|---|---|
committer | Timothy Pearson <[email protected]> | 2011-11-08 12:31:36 -0600 |
commit | d796c9dd933ab96ec83b9a634feedd5d32e1ba3f (patch) | |
tree | 6e3dcca4f77e20ec8966c666aac7c35bd4704053 /examples/wizard | |
download | tqt3-d796c9dd933ab96ec83b9a634feedd5d32e1ba3f.tar.gz tqt3-d796c9dd933ab96ec83b9a634feedd5d32e1ba3f.zip |
Test conversion to TQt3 from Qt3 8c6fc1f8e35fd264dd01c582ca5e7549b32ab731
Diffstat (limited to 'examples/wizard')
-rw-r--r-- | examples/wizard/main.cpp | 20 | ||||
-rw-r--r-- | examples/wizard/wizard.cpp | 226 | ||||
-rw-r--r-- | examples/wizard/wizard.doc | 29 | ||||
-rw-r--r-- | examples/wizard/wizard.h | 44 | ||||
-rw-r--r-- | examples/wizard/wizard.pro | 11 |
5 files changed, 330 insertions, 0 deletions
diff --git a/examples/wizard/main.cpp b/examples/wizard/main.cpp new file mode 100644 index 000000000..b7e4406dc --- /dev/null +++ b/examples/wizard/main.cpp @@ -0,0 +1,20 @@ +/**************************************************************************** +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of an example program for TQt. This example +** program may be used, distributed and modified without limitation. +** +*****************************************************************************/ + +#include "wizard.h" +#include <qapplication.h> + +int main(int argc,char **argv) +{ + TQApplication a(argc,argv); + + Wizard wizard; + wizard.setCaption("TQt Example - Wizard"); + return wizard.exec(); +} diff --git a/examples/wizard/wizard.cpp b/examples/wizard/wizard.cpp new file mode 100644 index 000000000..9440ab718 --- /dev/null +++ b/examples/wizard/wizard.cpp @@ -0,0 +1,226 @@ +/**************************************************************************** +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of an example program for TQt. This example +** program may be used, distributed and modified without limitation. +** +*****************************************************************************/ + +#include "wizard.h" + +#include <qwidget.h> +#include <qhbox.h> +#include <qvbox.h> +#include <qlabel.h> +#include <qlineedit.h> +#include <qpushbutton.h> +#include <qvalidator.h> +#include <qapplication.h> + +Wizard::Wizard( TQWidget *parent, const char *name ) + : TQWizard( parent, name, TRUE ) +{ + setupPage1(); + setupPage2(); + setupPage3(); + + key->setFocus(); +} + +void Wizard::setupPage1() +{ + page1 = new TQHBox( this ); + page1->setSpacing(8); + + TQLabel *info = new TQLabel( page1 ); + info->setMargin( 11 ); + info->setPalette( yellow ); + info->setText( "Enter your personal\n" + "key here.\n\n" + "Your personal key\n" + "consists of 4 digits" ); + info->setMaximumWidth( info->sizeHint().width() ); + + TQVBox *page = new TQVBox( page1 ); + + TQHBox *row1 = new TQHBox( page ); + + (void)new TQLabel( "Key:", row1 ); + + key = new TQLineEdit( row1 ); + key->setMaxLength( 4 ); + key->setValidator( new TQIntValidator( 1000, 9999, key ) ); + + connect( key, SIGNAL( textChanged( const TQString & ) ), + this, SLOT( keyChanged( const TQString & ) ) ); + + addPage( page1, "Personal Key" ); + + setNextEnabled( page1, FALSE ); + setHelpEnabled( page1, FALSE ); +} + +void Wizard::setupPage2() +{ + page2 = new TQHBox( this ); + page2->setSpacing(8); + + TQLabel *info = new TQLabel( page2 ); + info->setMargin( 11 ); + info->setPalette( yellow ); + info->setText( "\n" + "Enter your personal\n" + "data here.\n\n" + "The retquired fields are\n" + "First Name, Last Name \n" + "and E-Mail.\n" ); + info->setMaximumWidth( info->sizeHint().width() ); + + TQVBox *page = new TQVBox( page2 ); + + TQHBox *row1 = new TQHBox( page ); + TQHBox *row2 = new TQHBox( page ); + TQHBox *row3 = new TQHBox( page ); + TQHBox *row4 = new TQHBox( page ); + TQHBox *row5 = new TQHBox( page ); + + TQLabel *label1 = new TQLabel( " First Name: ", row1 ); + label1->setAlignment( TQt::AlignVCenter ); + TQLabel *label2 = new TQLabel( " Last Name: ", row2 ); + label2->setAlignment( TQt::AlignVCenter ); + TQLabel *label3 = new TQLabel( " Address: ", row3 ); + label3->setAlignment( TQt::AlignVCenter ); + TQLabel *label4 = new TQLabel( " Phone Number: ", row4 ); + label4->setAlignment( TQt::AlignVCenter ); + TQLabel *label5 = new TQLabel( " E-Mail: ", row5 ); + label5->setAlignment( TQt::AlignVCenter ); + + label1->setMinimumWidth( label4->sizeHint().width() ); + label2->setMinimumWidth( label4->sizeHint().width() ); + label3->setMinimumWidth( label4->sizeHint().width() ); + label4->setMinimumWidth( label4->sizeHint().width() ); + label5->setMinimumWidth( label4->sizeHint().width() ); + + firstName = new TQLineEdit( row1 ); + lastName = new TQLineEdit( row2 ); + address = new TQLineEdit( row3 ); + phone = new TQLineEdit( row4 ); + email = new TQLineEdit( row5 ); + + connect( firstName, SIGNAL( textChanged( const TQString & ) ), + this, SLOT( dataChanged( const TQString & ) ) ); + connect( lastName, SIGNAL( textChanged( const TQString & ) ), + this, SLOT( dataChanged( const TQString & ) ) ); + connect( email, SIGNAL( textChanged( const TQString & ) ), + this, SLOT( dataChanged( const TQString & ) ) ); + + addPage( page2, "Personal Data" ); + + setHelpEnabled( page2, FALSE ); +} + +void Wizard::setupPage3() +{ + page3 = new TQHBox( this ); + page3->setSpacing(8); + + TQLabel *info = new TQLabel( page3 ); + info->setPalette( yellow ); + info->setText( "\n" + "Look here to see of\n" + "the data you entered\n" + "is correct. To confirm,\n" + "press the [Finish] button\n" + "else go back to correct\n" + "mistakes." ); + info->setMargin( 11 ); + info->setAlignment( AlignTop|AlignLeft ); + info->setMaximumWidth( info->sizeHint().width() ); + + TQVBox *page = new TQVBox( page3 ); + + TQHBox *row1 = new TQHBox( page ); + TQHBox *row2 = new TQHBox( page ); + TQHBox *row3 = new TQHBox( page ); + TQHBox *row4 = new TQHBox( page ); + TQHBox *row5 = new TQHBox( page ); + TQHBox *row6 = new TQHBox( page ); + + TQLabel *label1 = new TQLabel( " Personal Key: ", row1 ); + label1->setAlignment( TQt::AlignVCenter ); + TQLabel *label2 = new TQLabel( " First Name: ", row2 ); + label2->setAlignment( TQt::AlignVCenter ); + TQLabel *label3 = new TQLabel( " Last Name: ", row3 ); + label3->setAlignment( TQt::AlignVCenter ); + TQLabel *label4 = new TQLabel( " Address: ", row4 ); + label4->setAlignment( TQt::AlignVCenter ); + TQLabel *label5 = new TQLabel( " Phone Number: ", row5 ); + label5->setAlignment( TQt::AlignVCenter ); + TQLabel *label6 = new TQLabel( " E-Mail: ", row6 ); + label6->setAlignment( TQt::AlignVCenter ); + + label1->setMinimumWidth( label1->sizeHint().width() ); + label2->setMinimumWidth( label1->sizeHint().width() ); + label3->setMinimumWidth( label1->sizeHint().width() ); + label4->setMinimumWidth( label1->sizeHint().width() ); + label5->setMinimumWidth( label1->sizeHint().width() ); + label6->setMinimumWidth( label1->sizeHint().width() ); + + lKey = new TQLabel( row1 ); + lFirstName = new TQLabel( row2 ); + lLastName = new TQLabel( row3 ); + lAddress = new TQLabel( row4 ); + lPhone = new TQLabel( row5 ); + lEmail = new TQLabel( row6 ); + + addPage( page3, "Finish" ); + + setFinishEnabled( page3, TRUE ); + setHelpEnabled( page3, FALSE ); +} + +void Wizard::showPage( TQWidget* page ) +{ + if ( page == page1 ) { + } else if ( page == page2 ) { + } else if ( page == page3 ) { + lKey->setText( key->text() ); + lFirstName->setText( firstName->text() ); + lLastName->setText( lastName->text() ); + lAddress->setText( address->text() ); + lPhone->setText( phone->text() ); + lEmail->setText( email->text() ); + } + + TQWizard::showPage(page); + + if ( page == page1 ) { + keyChanged( key->text() ); + key->setFocus(); + } else if ( page == page2 ) { + dataChanged( firstName->text() ); + firstName->setFocus(); + } else if ( page == page3 ) { + finishButton()->setEnabled( TRUE ); + finishButton()->setFocus(); + } +} + +void Wizard::keyChanged( const TQString &text ) +{ + TQString t = text; + int p = 0; + bool on = ( key->validator()->validate(t, p) == TQValidator::Acceptable ); + nextButton()->setEnabled( on ); +} + +void Wizard::dataChanged( const TQString & ) +{ + if ( !firstName->text().isEmpty() && + !lastName->text().isEmpty() && + !email->text().isEmpty() ) + nextButton()->setEnabled( TRUE ); + else + nextButton()->setEnabled( FALSE ); +} diff --git a/examples/wizard/wizard.doc b/examples/wizard/wizard.doc new file mode 100644 index 000000000..581e1b73a --- /dev/null +++ b/examples/wizard/wizard.doc @@ -0,0 +1,29 @@ +/* +*/ +/*! \page wizard-example.html + + \ingroup examples + \title Wizard + + This example shows the usage of Qt's wizard class. A wizard + should be used to help a user with complicated actions. + + <hr> + + Header file: + + \include wizard/wizard.h + + <hr> + + Implementation: + + \include wizard/wizard.cpp + + <hr> + + Main: + + \include wizard/main.cpp +*/ + diff --git a/examples/wizard/wizard.h b/examples/wizard/wizard.h new file mode 100644 index 000000000..f97a01fdf --- /dev/null +++ b/examples/wizard/wizard.h @@ -0,0 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of an example program for TQt. This example +** program may be used, distributed and modified without limitation. +** +*****************************************************************************/ + +#ifndef WIZARD_H +#define WIZARD_H + +#include <qwizard.h> + +class TQWidget; +class TQHBox; +class TQLineEdit; +class TQLabel; + +class Wizard : public TQWizard +{ + Q_OBJECT + +public: + Wizard( TQWidget *parent = 0, const char *name = 0 ); + + void showPage(TQWidget* page); + +protected: + void setupPage1(); + void setupPage2(); + void setupPage3(); + + TQHBox *page1, *page2, *page3; + TQLineEdit *key, *firstName, *lastName, *address, *phone, *email; + TQLabel *lKey, *lFirstName, *lLastName, *lAddress, *lPhone, *lEmail; + +protected slots: + void keyChanged( const TQString & ); + void dataChanged( const TQString & ); + +}; + +#endif diff --git a/examples/wizard/wizard.pro b/examples/wizard/wizard.pro new file mode 100644 index 000000000..0a85036a1 --- /dev/null +++ b/examples/wizard/wizard.pro @@ -0,0 +1,11 @@ +TEMPLATE = app +TARGET = wizard + +CONFIG += qt warn_on release +DEPENDPATH = ../../include + +REQUIRES = full-config + +HEADERS = wizard.h +SOURCES = main.cpp \ + wizard.cpp |