summaryrefslogtreecommitdiff
path: root/examples/simple
Unidiff
Diffstat (limited to 'examples/simple') (more/less context) (ignore whitespace changes)
-rw-r--r--examples/simple/simple.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/examples/simple/simple.cpp b/examples/simple/simple.cpp
index a0bc308..faf13c9 100644
--- a/examples/simple/simple.cpp
+++ b/examples/simple/simple.cpp
@@ -1,89 +1,91 @@
1#include <qlabel.h> // a label 1#include <qlabel.h> // a label
2#include <qpushbutton.h> // the header file for the QPushButton 2#include <qpushbutton.h> // the header file for the QPushButton
3#include <qlayout.h> 3#include <qlayout.h>
4 4
5#include <qpe/qpeapplication.h> // the QPEApplication 5#include <qpe/qpeapplication.h> // the QPEApplication
6 6
7#include <opie/oapplicationfactory.h> // a template + macro to save the main method and allow quick launching 7#include <opie2/oapplicationfactory.h> // a template + macro to save the main method and allow quick launching
8 8
9#include "simple.h" 9#include "simple.h"
10 10
11/* 11/*
12 * implementation of simple 12 * implementation of simple
13 */ 13 */
14 14
15/* 15/*
16 * The factory is used for quicklaunching 16 * The factory is used for quicklaunching
17 * It needs a constructor ( c'tor ) with at least QWidget, const char* and WFlags as parameter and a static QString appName() matching the TARGET of the .pro 17 * It needs a constructor ( c'tor ) with at least QWidget, const char* and WFlags as parameter and a static QString appName() matching the TARGET of the .pro
18 * 18 *
19 * Depending on the global quick launch setting this will create 19 * Depending on the global quick launch setting this will create
20 * either a main method or one for our component plugin system 20 * either a main method or one for our component plugin system
21 */ 21 */
22 22
23/* The OApplicationFactory is in Opie::Core */
24using namespace Opie::Core;
23OPIE_EXPORT_APP( OApplicationFactory<Simple> ) 25OPIE_EXPORT_APP( OApplicationFactory<Simple> )
24 26
25Simple::Simple( QWidget* parent, const char* name, WFlags fl ) 27Simple::Simple( QWidget* parent, const char* name, WFlags fl )
26 : QWidget( parent, name, fl ) { 28 : QWidget( parent, name, fl ) {
27 29
28 /* 30 /*
29 * sets the caption of this toplevel widget 31 * sets the caption of this toplevel widget
30 * put all translatable string into tr() 32 * put all translatable string into tr()
31 */ 33 */
32 setCaption(tr("My Simple Application") ); 34 setCaption(tr("My Simple Application") );
33 35
34 /* 36 /*
35 * A simple vertical layout 37 * A simple vertical layout
36 * either call layout->setAutoAdd( true ) 38 * either call layout->setAutoAdd( true )
37 * or use layout->addWidget( wid ) to add widgets 39 * or use layout->addWidget( wid ) to add widgets
38 */ 40 */
39 QVBoxLayout *layout = new QVBoxLayout( this ); 41 QVBoxLayout *layout = new QVBoxLayout( this );
40 layout->setSpacing( 8 ); 42 layout->setSpacing( 8 );
41 layout->setMargin( 11 ); 43 layout->setMargin( 11 );
42 44
43 /* 45 /*
44 * creates a label 46 * creates a label
45 * The first parameter is this widget so the Label is a child 47 * The first parameter is this widget so the Label is a child
46 * of us and will be deleted when we're deleted. 48 * of us and will be deleted when we're deleted.
47 */ 49 */
48 QLabel *lbl = new QLabel( this, "a name for the label" ); 50 QLabel *lbl = new QLabel( this, "a name for the label" );
49 lbl->setText( tr("Click on the button or follow the white rabbit") ); 51 lbl->setText( tr("Click on the button or follow the white rabbit") );
50 layout->addWidget( lbl ); 52 layout->addWidget( lbl );
51 53
52 54
53 /* creates a button as child of this widget */ 55 /* creates a button as child of this widget */
54 m_button = new QPushButton(this); 56 m_button = new QPushButton(this);
55 /* 57 /*
56 * another way to call tr. The first parameter is the string 58 * another way to call tr. The first parameter is the string
57 * to translate and the second a hint to the translator 59 * to translate and the second a hint to the translator
58 */ 60 */
59 m_button->setText( tr("Quit", "translatable quit string" ) ); 61 m_button->setText( tr("Quit", "translatable quit string" ) );
60 layout->addWidget( m_button ); 62 layout->addWidget( m_button );
61 63
62 /* 64 /*
63 * Now we bring the action into it. The power of qt is the dynamic 65 * Now we bring the action into it. The power of qt is the dynamic
64 * signal and slots model 66 * signal and slots model
65 * Usage is simple connect m_buttons clicked signal to our 67 * Usage is simple connect m_buttons clicked signal to our
66 * slotQuit slot. 68 * slotQuit slot.
67 * We could also have connected a SIGNAL to a SIGNAL or the clicked 69 * We could also have connected a SIGNAL to a SIGNAL or the clicked
68 * signal directly to qApp and SLOT(quit() ) 70 * signal directly to qApp and SLOT(quit() )
69 */ 71 */
70 connect( m_button, SIGNAL(clicked() ), 72 connect( m_button, SIGNAL(clicked() ),
71 this, SLOT( slotQuit() ) ); 73 this, SLOT( slotQuit() ) );
72} 74}
73 75
74/* 76/*
75 * Our destructor is empty because all child 77 * Our destructor is empty because all child
76 * widgets and layouts will be deleted by Qt. 78 * widgets and layouts will be deleted by Qt.
77 * Same applies to QObjects 79 * Same applies to QObjects
78 */ 80 */
79Simple::~Simple() { 81Simple::~Simple() {
80 82
81} 83}
82 84
83void Simple::slotQuit() { 85void Simple::slotQuit() {
84 /* 86 /*
85 * we will close this window and Qt will recognize that 87 * we will close this window and Qt will recognize that
86 * the last window was closed and initiate a shutdown 88 * the last window was closed and initiate a shutdown
87 */ 89 */
88 close(); 90 close();
89} 91}