Qt with Coin3D

Well, I do not know how many of you have heard of Qt and Coin3D. In this post, I will be telling you about these and how these two can be used together.

What is Qt?
Qt is a cross-platform application framework that is widely used for developing application software with a graphical user interface (GUI).

Qt can be implemented using following tools:
1.Qt Creator, a cross-platform IDE for C++ and QML. Qt Designer’s GUI layout/design functionality is integrated into this relatively new IDE, although Qt Designer can still be called as a standalone tool.
2.Qmake, a tool that automates the generation of Makefiles for development project across different platforms.


  1. Download the source file from http://qt-project.org/downloads according to your system.
  2. Next step is to run the .run file.
  3. First place it in your home directory.
  4. Type in terminal: sudo chmod a+x file-name.run.
  5. Execute ./file-name.run in terminal.
    In my case, I ran qt-opensource-linux-x64-5.2.1.run file and had qt-5.2.1 working on my system.

What is Coin3D?
Check for its installation in my previous post http://kamalpreetgrewal.wordpress.com/2014/03/13/coin3d/.

What is SoQt?
In order to implement Coin3D in Qt, SoQt is required. It acts as glue between Coin3D and Qt.
Type sudo apt-get install libsoqt4-dev in terminal. Now you have SoQt installed.

I had to use Coin3D with Qt. In order to accomplish this, I had to be clear how SoQt and Coin3D work.
The basic working principle is scenegraphs.

What is a scenegraph?
A graphical scene is logically represented using scenegraphs. A scene graph can be defined as collection of nodes in a graph or tree structure. I will be discuusing these in another post.
I created a simple program for cone. The program is:

#include <Inventor/Qt/SoQt.h>

include <Inventor/Qt/viewers/SoQtExaminerViewer.h>

include <Inventor/nodes/SoBaseColor.h>

include <Inventor/nodes/SoCone.h>

include <Inventor/nodes/SoSeparator.h>

int main(int argc, char * argv)
// Initializes SoQt library
mainwin = SoQt::init(argc, argv, argv[0]);

// Make a dead simple scene graph by using the Coin library.
SoSeparator * root = new SoSeparator;

SoBaseColor * col = new SoBaseColor;
col-&gt;rgb = SbColor(2, 3, 0);

root-&gt;addChild(new SoCone);

// Use one of the convenient SoQt viewer classes.
SoQtExaminerViewer * eviewer = new SoQtExaminerViewer(mainwin);

// Pop up the main window.
// Loop until exit.

// Clean up resources.
delete eviewer;

return 0;


The next step is open terminal and go to directory where you saved the file.
Follow these steps in terminal:

  1. qmake -project : generates cone.pro file
  2. qmake : generates Makefile
  3. make : In case of some errors regarding SoQt missing (or something similar), open Makefile. Go to LIBS. Append this line with -lSoQt -lCoin and you are done. Again run make.
  4. ./cone

An Examiner Viewer window will show a cone. That’s it. You used Coin3D with Qt. Yeah, was not tough so far. šŸ˜€ In case of any queries, do comment.

Leave a Reply