0

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

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 中运行。我想也许它缺少所有的插件。我错过了什么?

请帮忙。

4

1 回答 1

0

我解决了这个问题。

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

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

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

于 2013-09-24T16:21:08.567 回答