Hi Daniel
Thanks for your help. I tried nasa server within my app without success, rlayer is still invalid. I also tried within the QGis app, the server returned "this server no longer provide full WMS services!"... I also notice that my app starts immediatly, I'm not sure wether it should take some seconds or not.... Anyway, I added some paths in my app (defaultsvg and plugins), and now my wms server is "Valid'. But there's still nothing displayed in my map. Here's the current code regardings layers : QgsMapLayerRegistry::instance()->addMapLayer(rlayer); QList <QgsMapCanvasLayer> myLayerSet; myLayerSet.append(QgsMapCanvasLayer(rlayer, TRUE)); mapCanvas->setLayerSet(myLayerSet); mapCanvas->zoomScale(1/10000); mapCanvas->centerOn(5.7, 45.2); mapCanvas->update(); mapCanvas->refresh(); ________________________________ De : Daniel <daniel...@gmail.com> À : "chrome2006-...@yahoo.com" <chrome2006-...@yahoo.com> Cc : "qgis-developer@lists.osgeo.org" <qgis-developer@lists.osgeo.org> Envoyé le : Dimanche 6 octobre 2013 21h06 Objet : Re: [Qgis-developer] New QGis project, application : version is empty and wms layer invalid 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-...@yahoo.com <chrome2006-...@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@lists.osgeo.org >http://lists.osgeo.org/mailman/listinfo/qgis-developer > -- Daniel Vaz
_______________________________________________ Qgis-developer mailing list Qgis-developer@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/qgis-developer