00001 00002 /* 00003 * A Simple widget with a button to quit 00004 * 00005 */ 00006 00007 /* 00008 * The below sequence is called a guard and guards 00009 * against multiple inclusion of header files 00010 * NOTE: you need to use unique names among the header files 00011 */ 00012 #ifndef QUIET_SIMPLE_DEMO_H 00013 #define QUIET_SIMPLE_DEMO_H 00014 00015 00016 00017 00018 #include <qwidget.h> // from this class we will inherit 00019 00020 class QPushButton; // forward declaration to not include the header. This can save time when compiling 00021 00022 00023 /* 00024 * Simple inherits from QWidget 00025 */ 00026 class Simple : public QWidget { 00027 /* 00028 * Q_OBJECT must always be the first thing you include 00029 * This is a macro and is responsible for the concepts of 00030 * dynamic signal and slots and other MetaObjects as 00031 * superClass(), inherits(), isA()... 00032 * If you use multiple inheritance include the class derived 00033 * from QObject first 00034 */ 00035 Q_OBJECT 00036 public: 00037 /* 00038 * C'tor for the Simple 00039 * make sure to always have these three when you use 00040 * the quicklaunch factory ( explained in the implementation ) 00041 */ 00042 Simple( QWidget* parent = 0, const char * name = 0, WFlags fl = 0 ); 00043 ~Simple(); 00044 00045 /* 00046 * appName is used by the Application factory. 00047 * make sure the name matches the one of the executable 00048 */ 00049 static QString appName() { return QString::fromLatin1("simple"); } 00050 00051 /* 00052 * use private slots: to mark your slots as such 00053 * A slot can also be called as a normal method 00054 */ 00055 private slots: 00056 void slotQuit(); 00057 00058 private: 00059 /* my variable */ 00060 QPushButton* m_button; 00061 }; 00062 00063 00064 00065 00066 #endif
1.4.2