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:
int main(int argc, char ** argv)
// Initializes SoQt library
QWidget * mainwin = SoQt::init(argc, argv, argv);
// Make a dead simple scene graph by using the Coin library.
SoSeparator * root = new SoSeparator;
SoBaseColor * col = new SoBaseColor;
col->rgb = SbColor(2, 3, 0);
// Use one of the convenient SoQt viewer classes.
SoQtExaminerViewer * eviewer = new SoQtExaminerViewer(mainwin);
// Pop up the main window.
// Loop until exit.
// Clean up resources.
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.
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.