author | zecke <zecke> | 2004-03-14 20:08:59 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-03-14 20:08:59 (UTC) |
commit | 0d79c003839718ae70b3b997162044abd5c26bf6 (patch) (unidiff) | |
tree | 19708b041da3a09df8f3b571cd634a846f4ad6d7 /examples/simple-icon | |
parent | 05c8d999941989a97a581fb5822437034ec10fd7 (diff) | |
download | opie-0d79c003839718ae70b3b997162044abd5c26bf6.zip opie-0d79c003839718ae70b3b997162044abd5c26bf6.tar.gz opie-0d79c003839718ae70b3b997162044abd5c26bf6.tar.bz2 |
Update the Examples
-rw-r--r-- | examples/simple-icon/simple.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/examples/simple-icon/simple.cpp b/examples/simple-icon/simple.cpp index 054ade8..fec1823 100644 --- a/examples/simple-icon/simple.cpp +++ b/examples/simple-icon/simple.cpp | |||
@@ -1,100 +1,100 @@ | |||
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 | #include <qpe/resource.h> // for loading icon | 6 | #include <qpe/resource.h> // for loading icon |
7 | #include <qpe/sound.h> // for playing a sound | 7 | #include <qpe/sound.h> // for playing a sound |
8 | 8 | ||
9 | #include <opie/oapplicationfactory.h> // a template + macro to save the main method and allow quick launching | 9 | #include <opie2/oapplicationfactory.h> // a template + macro to save the main method and allow quick launching |
10 | 10 | ||
11 | #include "simple.h" | 11 | #include "simple.h" |
12 | 12 | ||
13 | /* | 13 | /* |
14 | * implementation of simple | 14 | * implementation of simple |
15 | */ | 15 | */ |
16 | 16 | ||
17 | /* | 17 | /* |
18 | * The factory is used for quicklaunching | 18 | * The factory is used for quicklaunching |
19 | * 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 | 19 | * 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 |
20 | * | 20 | * |
21 | * Depending on the global quick launch setting this will create | 21 | * Depending on the global quick launch setting this will create |
22 | * either a main method or one for our component plugin system | 22 | * either a main method or one for our component plugin system |
23 | */ | 23 | */ |
24 | 24 | using namespace Opie::Core; | |
25 | OPIE_EXPORT_APP( OApplicationFactory<Simple> ) | 25 | OPIE_EXPORT_APP( OApplicationFactory<Simple> ) |
26 | 26 | ||
27 | Simple::Simple( QWidget* parent, const char* name, WFlags fl ) | 27 | Simple::Simple( QWidget* parent, const char* name, WFlags fl ) |
28 | : QWidget( parent, name, fl ) { | 28 | : QWidget( parent, name, fl ) { |
29 | 29 | ||
30 | /* | 30 | /* |
31 | * sets the caption of this toplevel widget | 31 | * sets the caption of this toplevel widget |
32 | * put all translatable string into tr() | 32 | * put all translatable string into tr() |
33 | */ | 33 | */ |
34 | setCaption(tr("My Simple Application") ); | 34 | setCaption(tr("My Simple Application") ); |
35 | 35 | ||
36 | /* | 36 | /* |
37 | * A simple vertical layout | 37 | * A simple vertical layout |
38 | * either call layout->setAutoAdd( true ) | 38 | * either call layout->setAutoAdd( true ) |
39 | * or use layout->addWidget( wid ) to add widgets | 39 | * or use layout->addWidget( wid ) to add widgets |
40 | */ | 40 | */ |
41 | QVBoxLayout *layout = new QVBoxLayout( this ); | 41 | QVBoxLayout *layout = new QVBoxLayout( this ); |
42 | layout->setSpacing( 8 ); | 42 | layout->setSpacing( 8 ); |
43 | layout->setMargin( 11 ); | 43 | layout->setMargin( 11 ); |
44 | 44 | ||
45 | /* | 45 | /* |
46 | * creates a label | 46 | * creates a label |
47 | * 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 |
48 | * of us and will be deleted when we're deleted. | 48 | * of us and will be deleted when we're deleted. |
49 | */ | 49 | */ |
50 | QLabel *lbl = new QLabel( this, "a name for the label" ); | 50 | QLabel *lbl = new QLabel( this, "a name for the label" ); |
51 | /* | 51 | /* |
52 | * Resource will search hard for a Pixmap in $OPIEDIR/pics | 52 | * Resource will search hard for a Pixmap in $OPIEDIR/pics |
53 | * to find 'logo/opielogo' You need to pass the subdir | 53 | * to find 'logo/opielogo' You need to pass the subdir |
54 | * but not the ending | 54 | * but not the ending |
55 | */ | 55 | */ |
56 | lbl->setPixmap( Resource::loadPixmap("logo/opielogo") ); | 56 | lbl->setPixmap( Resource::loadPixmap("logo/opielogo") ); |
57 | layout->addWidget( lbl ); | 57 | layout->addWidget( lbl ); |
58 | 58 | ||
59 | 59 | ||
60 | /* creates a button as child of this widget */ | 60 | /* creates a button as child of this widget */ |
61 | m_button = new QPushButton(this); | 61 | m_button = new QPushButton(this); |
62 | /* | 62 | /* |
63 | * another way to call tr. The first parameter is the string | 63 | * another way to call tr. The first parameter is the string |
64 | * to translate and the second a hint to the translator | 64 | * to translate and the second a hint to the translator |
65 | */ | 65 | */ |
66 | m_button->setText( tr("Fire", "translatable fire string" ) ); | 66 | m_button->setText( tr("Fire", "translatable fire string" ) ); |
67 | layout->addWidget( m_button ); | 67 | layout->addWidget( m_button ); |
68 | 68 | ||
69 | /* | 69 | /* |
70 | * Now we bring the action into it. The power of qt is the dynamic | 70 | * Now we bring the action into it. The power of qt is the dynamic |
71 | * signal and slots model | 71 | * signal and slots model |
72 | * Usage is simple connect m_buttons clicked signal to our | 72 | * Usage is simple connect m_buttons clicked signal to our |
73 | * slotQuit slot. | 73 | * slotQuit slot. |
74 | * We could also have connected a SIGNAL to a SIGNAL or the clicked | 74 | * We could also have connected a SIGNAL to a SIGNAL or the clicked |
75 | * signal directly to qApp and SLOT(quit() ) | 75 | * signal directly to qApp and SLOT(quit() ) |
76 | */ | 76 | */ |
77 | connect( m_button, SIGNAL(clicked() ), | 77 | connect( m_button, SIGNAL(clicked() ), |
78 | this, SLOT( slotQuit() ) ); | 78 | this, SLOT( slotQuit() ) ); |
79 | } | 79 | } |
80 | 80 | ||
81 | /* | 81 | /* |
82 | * Our destructor is empty because all child | 82 | * Our destructor is empty because all child |
83 | * widgets and layouts will be deleted by Qt. | 83 | * widgets and layouts will be deleted by Qt. |
84 | * Same applies to QObjects | 84 | * Same applies to QObjects |
85 | */ | 85 | */ |
86 | Simple::~Simple() { | 86 | Simple::~Simple() { |
87 | 87 | ||
88 | } | 88 | } |
89 | 89 | ||
90 | void Simple::slotQuit() { | 90 | void Simple::slotQuit() { |
91 | /* | 91 | /* |
92 | * We will fire up a sound | 92 | * We will fire up a sound |
93 | * Note that Sound will use Resource as well | 93 | * Note that Sound will use Resource as well |
94 | * and we do not need to supply an ending | 94 | * and we do not need to supply an ending |
95 | * sounds are found in $OPIEDIR/sounds | 95 | * sounds are found in $OPIEDIR/sounds |
96 | */ | 96 | */ |
97 | Sound snd("hit_target01"); | 97 | Sound snd("hit_target01"); |
98 | snd.play(); | 98 | snd.play(); |
99 | 99 | ||
100 | } | 100 | } |