aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorItay Grudev <itay@grudev.com>2015-11-04 16:30:14 +0000
committerItay Grudev <itay@grudev.com>2015-11-04 16:30:14 +0000
commitbf00721b9c85a690a7be4f08d0828f6acf2f1287 (patch)
tree34564a8fb295807495007d80e07168e59c0c8fcd
parentUpdated implementation description (diff)
downloadsingleapplication-bf00721b9c85a690a7be4f08d0828f6acf2f1287.tar.xz
Improved QAPPLICATION_CLASS macro
Now it can be defined in the cpp file that include it (usually main.cpp).
-rw-r--r--README.md2
-rw-r--r--singleapplication.h4
2 files changed, 4 insertions, 2 deletions
diff --git a/README.md b/README.md
index 87d08ba..d458de5 100644
--- a/README.md
+++ b/README.md
@@ -42,7 +42,7 @@ Using ```QApplication::instance()``` is a neat way to get the ```SingleApplicati
Extending from other application classes
-----------------------
-```SingleApplication``` extends from the ```QApplication``` class by default , but you can easily change that to ```QGuiApplication``` or ```QCoreApplication``` from the ```singleapplication.h``` file, using the ```QAPPLICATION_CLASS``` macro.
+`SingleApplication` extends from the `QApplication` class by default , but you can easily change that to `QGuiApplication` or `QCoreApplication` with the `QAPPLICATION_CLASS` macro. Define it before the include statement of `singleapplication.h` or change the default value in the file.
__Example:__
diff --git a/singleapplication.h b/singleapplication.h
index 3766d61..1fe5c12 100644
--- a/singleapplication.h
+++ b/singleapplication.h
@@ -2,7 +2,9 @@
#define SINGLE_APPLICATION_H
// Change this to inherit from QGuiApplication or QCoreApplication
-#define QAPPLICATION_CLASS QApplication
+#ifndef QAPPLICATION_CLASS
+ #define QAPPLICATION_CLASS QCoreApplication
+#endif
#define QUOTE(C) #C
#define INCLUDE_FILE(C) QUOTE(C)