qgistestapp.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /***************************************************************************
  2. ----------------------------------------------------
  3. date : 4.1.2015
  4. copyright : (C) 2015 by Matthias Kuhn
  5. email : matthias.kuhn (at) opengis.ch
  6. ***************************************************************************
  7. * *
  8. * This program is free software; you can redistribute it and/or modify *
  9. * it under the terms of the GNU General Public License as published by *
  10. * the Free Software Foundation; either version 2 of the License, or *
  11. * (at your option) any later version. *
  12. * *
  13. ***************************************************************************/
  14. #ifndef QGISTESTAPP
  15. #define QGISTESTAPP
  16. #include <qgsapplication.h>
  17. class QgisTestApp
  18. {
  19. public:
  20. QgisTestApp()
  21. {
  22. int argc = 0;
  23. char **argv = 0;
  24. mApp = new QgsApplication( argc, argv, false );
  25. // load providers
  26. #if defined( Q_WS_WIN )
  27. QString prefixPath = QApplication::applicationDirPath();
  28. #else
  29. QString prefixPath = QApplication::applicationDirPath() + "/..";
  30. #endif
  31. mApp->setPrefixPath( prefixPath, true );
  32. #ifdef ANDROID
  33. mApp->setPluginPath( QApplication::applicationDirPath() );
  34. #else
  35. mApp->setPluginPath( "" QGIS_PLUGIN_DIR );
  36. #endif
  37. mApp->initQgis();
  38. }
  39. ~QgisTestApp()
  40. {
  41. #if 0
  42. // Crashes...
  43. delete mApp;
  44. #endif
  45. }
  46. private:
  47. QgsApplication *mApp;
  48. };
  49. #endif // QGISTESTAPP