KDE TechBase
  • Page
  • Discussion
  • Edit
  • History
KDE TechBase is a Wiki - You can help! Please contribute! Questions?
Please ask development related questions in the KDE Community Forum.

Projects/Marble/MarbleCPlusPlus

< Projects | Marble

Languages: عربي | Asturianu | Català | Česky | Kaszëbsczi | Dansk | Deutsch | English | Esperanto | Español | فارسی | Suomi | Français | Galego | Italiano | 日本語 | 한국어 | Norwegian | Polski | Português Brasileiro | Română | Русский | Svenska | Slovenščina | српски | Українська | 简体中文 | 繁體中文

Hello Marble
Tutorial Series   Marble C++ Tutorial
Prerequisites   C++, Qt
What's Next   Tutorial 2 - Marble's GeoPainter
Further Reading   n/a


[edit] Hello Marble!

The Marble API allows a very easy integration of a map widget into your application. Let's prove that with a tiny "Hello world"-like example:

#include <QtGui/QApplication>
#include <marble/MarbleWidget.h>
 
using namespace Marble;
 
int main(int argc, char** argv)
{
QApplication app(argc,argv);
 
// Create a Marble QWidget without a parent
MarbleWidget *mapWidget = new MarbleWidget();
 
// Load the OpenStreetMap map
mapWidget->setMapThemeId("earth/openstreetmap/openstreetmap.dgml");
 
// Set a server for downloading map data, if needed
mapWidget->setDownloadUrl("http://download.kde.org/apps/marble/");
mapWidget->show();
 
return app.exec();
}

Save the code above as my_marble.cpp and compile it:

g++ -I /usr/include/qt4/ -o my_marble my_marble.cpp -lmarblewidget -lQtGui

If things go fine, execute ./my_marble and you end up with a fully usable OpenStreetMap application: Image:My_marble.png

Here's a little checklist to tackle some problems that might arise when compiling the code above:

  • You need Qt and Marble development packages (or comparable SVN installations)
  • If you're running Marble from SVN, remove the setDownloadUrl() function call. It's obsolete and not needed anymore.
  • If Qt headers are not installed in /usr/include/qt4 on your system, change the path in the g++ call above accordingly.
  • Likewise, add -I /path/to/marble/headers if they're not to be found in /usr/include
Retrieved from "http://techbase.kde.org/Projects/Marble/MarbleCPlusPlus"
Category: Tutorial

Navigation

  • Home
  • Help
  • Recent changes

Sections

  • Getting started
  • Development
  • Schedules
  • Policies
  • Contribute
  • Projects

Toolbox

  • What links here
  • Related changes
  • Special pages
  • Printable version
  • Permanent link

Personal tools

  • 38.107.191.97
  • Talk for this IP
  • Log in / create account
  • Login with OpenID
Creative Commons License SA 3.0 as well as the GNU Free Documentation License 1.2
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal