#include "hello.h" #include <qmultilineedit.h> #include <qpushbutton.h> #include <qlayout.h> void Hello::quit () { MyConfiguration->writeEntry("counter", counter); // write the counter value delete MyConfiguration; this->close(); } void Hello::work () { EditField->append ( tr( "%1 little PDA%2 sitting in a cradle..." ).arg(counter) .arg((counter>1)?"s":"") ); counter++; } Hello::Hello( QWidget* parent, const char* name, WFlags fl ) : QWidget( parent, name, fl ) { if ( !name ) setName( "Hello" ); setCaption( tr( "Hello there!" ) ); HelloLayout = new QGridLayout( this ); HelloLayout->setSpacing( 5 ); HelloLayout->setMargin( 10 ); ExitButton = new QPushButton( this, "ExitButton" ); ExitButton->setText( tr( "Exit" ) ); HelloLayout->addWidget( ExitButton, 1, 1 ); WorkButton = new QPushButton( this, "WorkButton" ); WorkButton->setText( tr( "Work" ) ); HelloLayout->addWidget( WorkButton, 1, 0 ); EditField = new QMultiLineEdit( this, "EditField" ); HelloLayout->addMultiCellWidget ( EditField, 0, 0, 0, 1 ); connect ( ExitButton, SIGNAL(clicked()), this, SLOT(quit()) ); connect ( WorkButton, SIGNAL(clicked()), this, SLOT(work()) ); MyConfiguration=new Config(tr("hello")); // Create Qtopia Config object for // application hello MyConfiguration->setGroup("hello group"); // Name-space within the application configuration counter=MyConfiguration->readNumEntry("counter",1); // Read the counter from configuration work(); }