0

I followed the instructions here:

How to install QGIS on Centos 6?

If I run:

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

Then provider is a NULL pointer

Also, if I do:

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

Then it prints:

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

Also, when I try to load a QgsVectorLayer with the following:

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

Then it says that the layer is NOT valid.

This all works just fine in Ubuntu, but I can't get it to work in centos. I think maybe it's missing all the plugins. What am I missing?

Please help.

1 Answer 1

0

I figured out the problem.

It was unrelated to the code I posted. Hopefully this will be helpful to others that get a similar error.

My code was templated from the QGIS_-Code-Examples (2_basic_main_window)

I didn't change the myPluginsDir variable. Be sure that you change it because by default it will be wrong.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.