Featured post


Qanava is an open source LGPL’ed C++ library designed to display graphs in a Qt graphics view. Qanava provide classes to generate various layouts of directed graphs and visualize their nodes with custom styles on a graphic canvas.

Qanava source repository is hosted on Gitorious: https://gitorious.org/qanava

Qanava is primarily developed with Qt Creator (MSVC 2012) and Qt 5.4 but compiles well with G++ for Linux and GCC-ARM for Android. Qanava depends on Qt property browser: https://qt.gitorious.org/qt-solutions/qt-solutions

For any questions, please contact: benoit@qanava.org

Qanava also include a simple graphics widget container for QGraphicsView with a standalone windowing system (qan::ContainerGraphicsItem could be used without a full Qanava dependency):

QanMenuBar pushed to GIT repository

QanMenuBar is a simple dynamic QML based menu (with both a declarative and c++ interface based on QAction). QanMenuBar will be used in Qanava samples, and maintained in the library into a separate directory. (‘qmlmenubar’). QanMenuBar is reusable outside of the library without any dependency on Qanava (just add Qan*.qml files to your project resources, then configure project .pro as in ‘qmlmenubar.pro’).

20150110_NP_menubar-unvlopped         20150110_NP_menubar-expanded

Documentation will come with the 0.9.3 final release, have a look to: https://gitorious.org/qanava/qanava/source/qmlmenubar

Qanava 0.9.3 preview

Qanava 0.9.3 preview has been pushed to the GITorious repository. Nodes groups management has been deeply modified and the existing graphics container item has been totally rewritten in a more clean and modular way :

  • Class qan::GraphicsContainer now replace qan::ContainerGraphicsItem to provide an efficient graphics widget (and graphics item) container system. Graphics container now provide a rectangular (“square” setting) area for tour graphics widgets with a Qt Creator style window decoration (but without the cost of QGraphicsWidget and its horrible Qt::Window creation flag). Original “round” style is still fully supported.
  • Qanava provide two new controllers items:
    • qan::GraphicsController add a close, minimize/maximize and develop/unvlop button, along with automatic focus shadow.
    • qan::GraphicsResizer add resizing support for any QGraphicsItem object implementing the standard graphics layout interface (QGraphicsLayoutItem).
  • Qanava nodes groups could now be laid out with graphics linear layout (QGraphicsLinearLayout). Linear layout can also be used inside groups along with Qanava layouts such has hierarchy trees or dynamic undirected graphs.

QTextEdit widgets in a graphics view in the content area of a Qanava graphics container


QGraphicsView with a a graphics pixmap item used as a Qanava container content trough a graphics widget proxy


Graphics view showing a label based on QLabel trough a graphics widget proxy with a Qanava controller (with a close/minimize/maximize and focus shadow)

Class qan::ContainerGraphicsItem is now deprecated and has been removed from the source tree.

Warning 1 : Qanava controllers relies on scene events filters, using controller on existing graphics items using events filters could lead to events ventilation problems in your code (contact me if it is open source).

Warning 2 : Qt >=5.4 should be used or Qanava will be affected by QTBUG-20132 : https://bugreports.qt-project.org/browse/QTBUG-20132, and graphics controllers expand button will not work (it will not lead to a crash with previous versions).

Qanava v0.9.2

Qanava-0.9.2 brings full GCC and a preliminary Android support. Actually, Qt Touch support is limited to pinch zomming on Android, using touch for item panning and zomming would probably boost performances in next releases. Creating custom graphics nodes is now easier thanks to a new qan::SimpleNodeItem class, have a look to the new ‘custom’ example that show how to extend Qanava with user defined graphics nodes (a tutorial will be published soon). Standard edge intersection code has been updated to take item shape into account and not only their bounding boxes. Qanava is now primarily developped with QtCreator, build is simplified with a unique ‘qanava.pro’ entry point, you can then select a kit for your favorite platform (I’am still interested in Linux/KDE screenshots…).

Download: http://www.qanava.org/dl/qanava-0.9.2.zip

Gitorious: https://gitorious.org/qanava


Next Qanava version will bring QTCreator, GCC and Android support

A major Qanava update will be released soon with full GCC (in fact 9.1.0 code wasn’t compiling with GCC, sorry for that) and Android support. The build configuration has been deeply modified for better QT Creator kit support, and you can now easily compile on Windows MSVC or GCC (and MingWin ARM for Android). Projects files for visual studio could still be generated as in 0.9.1 (BTW, Qt Creator is a lot more efficient than Visual…).

Do not hack the code by yourself for GCC, just email me for the latest version until I configure a GIT account for Qanava. I’am looking for feedback and screenshots on a Linux build.


Tutorial 1 : Qanava graph model, creating a simple graph

Qanava has a model/view architecture with a graph model encoding graph topology and two intermediate views exposing the graph topology to both Qt Interview widgets and Qt Graphics View:


Configuring a simple Qanava view :

 // Create a graph model object
 qan::Graph* graph = new qan::Graph( );

 // Create, then configure a graph view object
 qan::GraphView* graphView = new qan::GraphView( this, Qt::white );
 graphView->setGraph( *graph );
 hbox->addWidget( graphView ); // Add the view to an existing layout

Graph model could be populated by adding nodes and edges with dedicated methods, the associated view will be updated automatically :

 qan::Node* q = new qan::Node( "Q" );
 graph->insertNode( q );

 qan::Node* a = new qan::Node( "a" );
 graph->insertNode( a );

 qan::Node* n = new qan::Node( "n" );
 graph->insertNode( a );

 qan::Edge* qa = graph->insertEdge( *q, *a );
 qan::Edge* an = graph->insertEdge( *a, *n );


 // Creating a node group
 qan::NodeGroup* group = new qan::NodeGroup( _graph->getM( ), "Node Group" );
 treeGroup->setLayout( new qan::HierarchyTree( ) );
 graph->getM( ).addNodeGroup( *group );
 qan::Node* n1 = graph->insertNode( "N1" );
 qan::Node* n2 = graph->insertNode( "N2" );
 qan::Edge* n1n2 = graph->insertEdge( *n1, *n2 );
 group->addNode( *n1 );
 group->addNode( *n2 );



Qanava features

Qanava models directed node/edge graphs who are internally stored in a standard node/edge list model. Edges are not weighted by default, but a weight property can be added dynamically. The main class for modeling graphs is qan::Graph who store lists of qan::Node and qan::Edge.

The graph model class can be viewed Qt Interview or Qt Graphics View via qan::GraphScene and qan::GraphModel classes. A qan::Graph instance automatically maintain theses two corresponding objects (via a standard listener) that could be accessed by the user to populate the needed views. Have a look at tutorial 1: Creating a simple graph.

Library comes with ready to use widgets allowing the user to interact with the graph :

  • View tools : simple toolbar widget controlling a Qt Graphics View (and qan::GraphView) to allow user to zoom in/out, navigate via panning or select an area to perform a « window zoom ».

  • Style management : associate style to node and edge and provide a complete style graphic editor (qan::StyleEditor) and a graphics widget allowing to apply styles dynamically by dropping a style preview to an arbitrary node.

  • Grid drawing : qan::Grid subclasses could draw simple grids (actually that code is quite outdated and is just an efficient way to draw check-board style grids).

  • Group management : nodes could be sorted by groups, and the user can drag an drop nodes to populate its groups (qan::NodeGroup), groups could actually be seen like a pure hyper-edge implementation.

  • Custom window container : qan::GraphicsContainer avoid the use of QGraphicsWidget that generate platform dependent windows decorations with an easy to use and fast QGraphicsItem based container showing a window decoration (it could actually display a title, allow window moving, resizing and minimization).

Qanava is not designed to visualize large graphs using complex layout algorithms, but rather to display very specific medium sized graphs with complex properties in an advanced graphical user interface.

Qanava 0.9.1 installation

(note 2014/12/29: this post is outdated, have a look at: http://www.qanava.org/doc)

For Windows with QT 5.3 and Visual Studio > 2011:

First, you need to get the latest Qanava archive on : http://www.qanava.org/dl (qanava-0.9.1-ceyx.zip), and unzip it in a local directory, for example : c:\qanava-0.9.1 (referred as $(QANAVADIR))

Now, get qtpropertybrowser in he qt-tools (and not in qt-solutions) GIT repository : https://qt.gitorious.org/qt/qttools (in the src/shared/propertybrowser directory, altough it is now largely unmaintened)

Or directly from an official Qt release .zip archive, for example for Qt 5.3.2: http://download.qt-project.org/official_releases/qt/5.3/5.3.2/submodules/qttools-opensource-src-5.3.2.zip

Now, qtpropertybrowser, by modifying the qtpropertybrowser.pri file to support static linking in both release and debug mode. Add the following configuration settings at the head of the .pri file :

TARGET = libpropertybrowser
CONFIG += debug warn_on qt thread staticlib

Release:DESTDIR = release
Release:TARGET = libpropertybrowser
Release:OBJECTS_DIR = release/.obj
Release:MOC_DIR = release/.moc
Release:RCC_DIR = release/.rcc
Release:UI_DIR = release/.ui

Debug:DESTDIR = debug
Debug:TARGET = libpropertybrowserd
Debug:OBJECTS_DIR = debug/.obj
Debug:MOC_DIR = debug/.moc
Debug:RCC_DIR = debug/.rcc
Debug:UI_DIR = debug/.ui

Then, generate a visual studio project file to compile libpropertbrowser with the following command : “qmake -t vclib qtpropertybrowser.pri” and compile in both release and debug from the visual studio IDE. Do not forget to add a QTPROPERTYBROWSER environnement variable pointing to the root of this source directory, since it is used later in Qanava build configuration.

Then, in $(QANAVADIR)\build\qan, just use the following command “qmake -t vclib” to generate Qanava project file.

Examples and tests could be built in the same way, generating their project’s file using the “qmake -t vcapp” command, and inserting the resulting project in a solution with qanava.vcproj.