[Qgis-developer] New QGis project, application : version is empty and wms layer invalid

Daniel danielvaz at gmail.com
Sun Oct 6 12:06:51 PDT 2013


I don't know if you should receive "2.0" as output of applicationVersion()
method.

It's because setApplicationVersion() and setApplicationName() are called
from src/core/main.cpp (QGIS code).

The class QgsApplication don't call setter methods, so I don't know what
are the supposed behavior when I call these methods.

It works for me

QString uri= "url=
http://wms.jpl.nasa.gov/wms.cgi&crs=EPSG:4326&format=image/jpeg&layers=global_mosaic&styles=pseudo
";
qDebug() << "uri" << uri;
QgsRasterLayer *rlayer = new QgsRasterLayer(uri, "layer_name", "wms",
false);
qDebug() << rlayer->isValid();


Hope it helps you



On Sun, Oct 6, 2013 at 2:32 PM, chrome2006-dev at yahoo.com <
chrome2006-dev at yahoo.com> wrote:

>
> Hi
>
> This is my first attemp with QGIS. I'm using 2.0 version.
> My first goal is a proof of concept with a wms map and a vector map.
> I started with the wms service. You'll find the code below, there are two
> things that don't go well.
>
> First, QgsApplication::applicationVersion() is "", Did I do something
> wrong in
> initialization ?
>
> Second, my wms layer is not valid but maybe it is only because of the
> first question...
>
>
> main.cpp
> int main(int argc, char *argv[])
> {
>     QgsApplication app(argc, argv, TRUE);
>     MainWindow w;
>     w.show();
>
>     return app.exec();
> }
>
>
> mainwindow.cpp
>
> MainWindow::MainWindow(QWidget *parent) :
>     QMainWindow(parent),
>     ui(new Ui::MainWindow)
> {
>     ui->setupUi(this);
>     QgsApplication::setPrefixPath("/usr/lib/qgis", false);
>     QgsApplication::initQgis();
>     qDebug()<< QgsApplication::applicationVersion();     //
> <<------------------- return empty string
>
>     mapCanvas = new QgsMapCanvas(this);
>     mapCanvas->enableAntiAliasing(true);
>     mapCanvas->useImageToRender(false);
>     mapCanvas->setCanvasColor(QColor(255, 255, 255));
>     mapCanvas->freeze(false);
>     mapCanvas->setVisible(true);
>     mapCanvas->refresh();
>     mapCanvas->show();
>
>     QVBoxLayout* lyt = new QVBoxLayout(ui->centralWidget);
>     lyt->addWidget(mapCanvas);
>
>     QString uri =
> "crs=EPSG:4326&featureCount=10&format=image/gif&layers=osm_auto:all&styles=&url=
> http://129.206.228.72/cached/osm";
>     QgsRasterLayer* rlayer = new  QgsRasterLayer(uri, "test", "wms", true);
>     if (!rlayer->isValid()) qDebug() <<"invalid wms";   //
> <<--------------------- It is invalid !
>
>     QgsMapLayerRegistry::instance()->addMapLayer(rlayer);
>
>     mapCanvas->layers().append(rlayer);
>     mapCanvas->zoomScale(1/10000);
>     mapCanvas->centerOn(5.7, 45.2);
>     mapCanvas->update();
> }
>
> Thanks for your help.
> Regards
> Juliette
>
>
>
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-developer
>



-- 
Daniel Vaz
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20131006/e06afc35/attachment.html>


More information about the Qgis-developer mailing list