testqgsapplication.cpp

来自「一个非常好的GIS开源新版本」· C++ 代码 · 共 78 行

CPP
78
字号
/***************************************************************************  testqgsapplication.cpp  --------------------------------------Date                 : Sun Sep 16 12:22:49 AKDT 2007Copyright            : (C) 2007 by Gary E. ShermanEmail                : sherman at mrcc dot com *************************************************************************** *                                                                         * *   This program is free software; you can redistribute it and/or modify  * *   it under the terms of the GNU General Public License as published by  * *   the Free Software Foundation; either version 2 of the License, or     * *   (at your option) any later version.                                   * *                                                                         * ***************************************************************************/#include <QtTest>#include <iostream>#include <QPixmap>#include <qgsapplication.h>//header for class being tested#include <qgsapplication.h>class TestQgsApplication: public QObject{  Q_OBJECT;  private slots:    void getPaths();    void checkTheme();  private:    QString getQgisPath();};QString TestQgsApplication::getQgisPath(){#ifdef Q_OS_LINUX   QString qgisPath = QCoreApplication::applicationDirPath () + "/../";#else //mac and win  QString qgisPath = QCoreApplication::applicationDirPath () ;#endif  return qgisPath;}void TestQgsApplication::getPaths(){  // init QGIS's paths - true means that all path will be inited from prefix  QgsApplication::setPrefixPath(getQgisPath(), TRUE);  std::cout << "Prefix  PATH: " << QgsApplication::prefixPath().toLocal8Bit().data() << std::endl;  std::cout << "Plugin  PATH: " << QgsApplication::pluginPath().toLocal8Bit().data() << std::endl;  std::cout << "PkgData PATH: " << QgsApplication::pkgDataPath().toLocal8Bit().data() << std::endl;  std::cout << "User DB PATH: " << QgsApplication::qgisUserDbFilePath().toLocal8Bit().data() << std::endl;};void TestQgsApplication::checkTheme(){  QgsApplication::setPrefixPath(getQgisPath(), TRUE);  std::cout << "Prefix  PATH: " << QgsApplication::prefixPath().toLocal8Bit().data() << std::endl;  std::cout << "Plugin  PATH: " << QgsApplication::pluginPath().toLocal8Bit().data() << std::endl;  std::cout << "PkgData PATH: " << QgsApplication::pkgDataPath().toLocal8Bit().data() << std::endl;  std::cout << "User DB PATH: " << QgsApplication::qgisUserDbFilePath().toLocal8Bit().data() << std::endl;  QString myIconPath = QgsApplication::themePath();  QPixmap myPixmap;  myPixmap.load(myIconPath+"/mIconProjectionDisabled.png");  qDebug("Checking if a theme icon exists:");  qDebug(myIconPath.toLocal8Bit()+"/mIconProjectionDisabled.png");  QVERIFY(!myPixmap.isNull());};QTEST_MAIN(TestQgsApplication)#include "moc_testqgsapplication.cxx"

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?