Fixed problem with addNode() method thanks to qtcentre forum.