summaryrefslogtreecommitdiff
path: root/examples/simple-main/simple.h
Unidiff
Diffstat (limited to 'examples/simple-main/simple.h') (more/less context) (show whitespace changes)
-rw-r--r--examples/simple-main/simple.h81
1 files changed, 81 insertions, 0 deletions
diff --git a/examples/simple-main/simple.h b/examples/simple-main/simple.h
new file mode 100644
index 0000000..f75066e
--- a/dev/null
+++ b/examples/simple-main/simple.h
@@ -0,0 +1,81 @@
1
2/*
3 * A Simple widget with a button to quit
4 *
5 */
6
7/*
8 * The below sequence is called a guard and guards
9 * against multiple inclusion of header files
10 * NOTE: you need to use unique names among the header files
11 */
12#ifndef QUIET_SIMPLE_DEMO_H
13#define QUIET_SIMPLE_DEMO_H
14
15
16
17
18#include <qmainwindow.h> // from this class we will inherit
19
20
21class QPushButton; // forward declaration to not include the header. This can save time when compiling
22class QAction;
23
24/*
25 * A mainwindow is a special QWidget it helps layouting
26 * toolbar, statusbar, menubar. Got dockable areas
27 * So in one sentence it is a MainWindow :)
28 */
29class MainWindow : public QMainWindow {
30 Q_OBJECT
31public:
32 static QString appName() { return QString::fromLatin1("simple-main"); }
33 MainWindow( QWidget* parent, const char* name, WFlags fl );
34 ~MainWindow();
35
36public slots:
37 void setDocument( const QString& );
38
39private:
40 void initUI();
41 QAction *m_fire;
42};
43
44
45/*
46 * Simple inherits from QWidget
47 */
48class Simple : public QWidget {
49 /*
50 * Q_OBJECT must always be the first thing you include
51 * This is a macro and is responsible for the concepts of
52 * dynamic signal and slots and other MetaObjects as
53 * superClass(), inherits(), isA()...
54 * If you use multiple inheritance include the class derived
55 * from QObject first
56 */
57 Q_OBJECT
58public:
59 /*
60 * C'tor for the Simple
61 * make sure to always have these three when you use
62 * the quicklaunch factory ( explained in the implementation )
63 */
64 Simple( QWidget* parent = 0, const char * name = 0, WFlags fl = 0 );
65 ~Simple();
66
67 /*
68 * We now make it public because our mainwindow wants to call it
69 */
70public slots:
71 void slotFire();
72
73private:
74 /* my variable */
75 QPushButton* m_button;
76};
77
78
79
80
81#endif