The following project shows how to embbed Google Maps into a Qt application and how to control the map motion programatically.

The user interface is made of one QWebView containing a custom web page, and five QPushButton to move the map:


The Google Maps widget is a web page displayed in a QWebView QWidget:

mView = new QWebView( this );
QString fileName = qApp->applicationDirPath() + "/map.html";
QUrl url = QUrl::fromLocalFile( fileName );
mView->load( url );

The web page source code comes from a basic Google Maps API example, except that the link to the source of the javascript should be “http” instead of “https”:

<script type=”text/javascript” src=”http://maps.googleapis.com/maps/api/js?sensor=false”></script&gt;
<script type=”text/javascript”>
var map;

var myLatlng = new google.maps.LatLng(45.20297, 5.6995);

function initialize() {
var myOptions = {
zoom: 14,
center: new google.maps.LatLng(45.20297, 5.6995),
mapTypeId: google.maps.MapTypeId.HYBRID,
zoomControl: true,
zoomControlOptions: { style: google.maps.ZoomControlStyle.SMALL },

map = new google.maps.Map(document.getElementById(‘map_canvas’), myOptions);

google.maps.event.addDomListener(window, ‘load’, initialize);


<div id=”map_canvas”></div>

Data is passed from the Qt application to the webpage using javascript. For example the following line will execute a javascript command to pan the map by 0 pixel in the x-axis direction and -10 pixels in the y-axis direction:

mView->page()->mainFrame()->evaluateJavaScript("map.panBy(0, -10);");

The source code of this project can be found here: https://docs.google.com/open?id=0B5yDBZt8fDFhNUpSeUZSaE1MU0E or there: http://github.com/adrienbailly/qmaps


Google Maps API Documentation: https://developers.google.com/maps/documentation/javascript/reference

QT QWebView Documentation: http://qt-project.org/doc/qt-4.8/qwebview.html


Microchip C18 compiler has the annoying habit of throwing warning #2058 (call of function without prototype) when you call a function taking no parameters even though the function prototype is declared. The solution is to add the ‘void’ keyword in place of the parameters in the function protoype:

char foo(); // this will cause a warning #2058 ...
char bar(void); // ... but this won't.

If you are working an a distant computer or a virtual machine this will help you:
$ cat /etc/issue
Ubuntu 10.04 LTS \n \l

For the kernel version:
$ uname -a
Linux tatooine 2.6.32-22-generic #33-Ubuntu SMP Wed Apr 28 13:28:05 UTC 2010 x86_64 GNU/Linux

To display the amount of free and used memory:
$ free -m
total used free shared buffers cached
Mem: 3896 3557 339 0 336 1023
-/+ buffers/cache: 2196 1700
Swap: 1155 0 1155

To gather some data about your hardware try lshw:
$ sudo lshw
description: Computer
width: 64 bits
capabilities: vsyscall64 vsyscall32
description: Motherboard
physical id: 0
description: System memory
physical id: 0
size: 3896MiB

$ sudo apt-get install php5-cli

apt is probably still running in the background, wait until it finished. If it’s frozen kill the processes:
$ sudo pkill apt

Size of a directory

To know the size the current including all the subdirectories:
$ du -sh .

-s : only show the total size (ie: not the size of all files and subdirectory)
-h : display in Kb, Mb, Gb instead of byte only


<input type="submit" value="Go"></input>


<input type="submit" value="Go" style="display:block;margin:0 auto;"></input>