【问题标题】:How to create a QgsVectorLayer in qgis in centos (maybe missing plugins package?)如何在centos中的qgis中创建QgsVectorLayer(可能缺少插件包?)
【发布时间】:2013-09-23 11:46:20
【问题描述】:

我按照这里的说明进行操作:

https://gis.stackexchange.com/questions/37111/how-to-install-qgis-on-centos-6

如果我跑:

QgsVectorLayer * vpoly = new QgsVectorLayer("Polygon", "pointbuffer", "memory");
QgsVectorDataProvider * provider = vpoly->dataProvider();

那么provider就是一个NULL指针

另外,如果我这样做:

QString myPluginsDir = "/usr/lib64/qgis";
QgsProviderRegistry * preg = QgsProviderRegistry::instance(myPluginsDir);
QString pluglist=preg->pluginList();
printf("plugins: %s\n",pluglist.toStdString().c_str());

然后打印:

plugins: No data provider plugins are available. No vector layers can be loaded

此外,当我尝试使用以下内容加载 QgsVectorLayer 时:

QgsVectorLayer * mypLayer = new QgsVectorLayer(myLayerPath, myLayerBaseName,    myProviderName);
if (mypLayer->isValid()){
    qDebug("Layer is valid");
} else {
    qDebug("Layer is NOT valid");
    return;
}

然后它说该层无效。

这一切在 Ubuntu 中运行良好,但我无法在 centos 中运行。我想也许它缺少所有的插件。我错过了什么?

请帮忙。

【问题讨论】:

    标签: c++ centos gis qgis


    【解决方案1】:

    我发现了问题所在。

    这与我发布的代码无关。 Heopfully 这将对遇到类似错误的其他人有所帮助。

    我的代码是从 QGIS_-Code-Examples (2_basic_main_window) 模板化的

    我没有更改 myPluginsDir 变量。请务必更改它,因为默认情况下它是错误的。

    【讨论】:

      猜你喜欢
      • 2015-10-22
      • 2014-12-02
      • 2020-02-18
      • 2019-03-14
      • 2015-04-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-11-22
      相关资源
      最近更新 更多