PDA

View Full Version : how to embed Coin3d window in Qt application?



vonCZ
1st May 2007, 18:51
I've created a very simple Qt application with a few pushButtons. I now need to embed a Coin3d (OpenInventor) window inside my Qt application. I've gotten a couple pointers on how to do this from folks on a Coin3d forum, but I'm running into some problems.

My code includes a

#include <Inventor/Qt/SoQt.h>

header which wasn't found until I edited the vsvars32.bat file. (should I have done this?) Now, however, I'm receiving the following error message:

C:\coin3d\include\Inventor\Qt\SoQtBasic.h(130) : fatal error C1189: #error : Define either SOQT_DLL or SOQT_NOT_DLL as appropriate for your linkage!

I'm using MSVC++ 2005 Express to compile: qmake -project ; qmake ; nmake in the Visual Studio 2005 Command Prompt. Given the inclusion of extraneous/non-Qt stuff, do I need to go about compiling this differently? ...edit one of the Makefiles or use additional arguments when running qmake?

marcel
1st May 2007, 19:03
No, all you have to do is define of the two, depending if you want to use SOQt as dll , or as static lib.

Either way, all you have to do is to open the project properties dialog ( in Visual Studio ), and add SOQT_DLL or SOQT_NOT_DLL to C/C++->Preprocessor->Preprocessor definitions.

And that's it. Should work fine now.

vonCZ
2nd May 2007, 07:00
Either way, all you have to do is to open the project properties dialog ( in Visual Studio ), and add SOQT_DLL or SOQT_NOT_DLL to C/C++->Preprocessor->Preprocessor definitions.


this is how I've done it, when building a Coin/OpenInventor executable. However, with Qt I am not using MSVC++ gui/menus, etc... just the MSVC command prompt and:

qmake -project
qmake
nmake

so there is no project (or project properties dialog) for me to set the Preprocessor definitions.

pdolbey
2nd May 2007, 21:03
Here's a bare bones project for a SoQtExaminerViewer. I assume you've qtwin'd yoyr Qt environment.

Before using this create an environment variable called COINDIR to point to yoyr Coin3d environment - mine is set to F:\Coin3d. Also add "%COINDIR%\bin" to your system path.

Expand the 2 files and open a "cmd" prompt in the folder. Run

"qmake -tp vc"

This will create file Coin3d.vcproj - load this into VS2005. Build the exe - you'll be asked to save the Coin3.sln file first. Enjoy the viewer.

You should be able to use this as a template. Even though I develop and debug in VS2005, if I have any changes to configuration such adding as new file or DEFINES, I'll edit the .pro file and regenerate the .vcproj as above - it ends being much simpler and more reliable to maintain.

Pete

vonCZ
3rd May 2007, 09:01
Awww Pete, you really got my hopes up, but I think you posted the wrong .zip file: the template you posted is a stand-alone Coin application with no Qt interface/widgets (except for the call to SoQt instead of SoWin). Do you/anyone have a simple Qt template program that includes a Coin render window? Something like the

examples/opengl/hellogl

program?

pdolbey
3rd May 2007, 14:04
The point of the zip file file was more to do with the managment of the compiler environment settings than the simple application itself. If you want an example of how to embed a Coin3d window into an application, head over to http://sourceforge.net/projects/free-cad and grab the source fron the SVN trunk. This is an application that renders a OpenCascade CAD model in a Coin3d window - the current SVN code is migrating from Qt3 to Qt4.

You could try replacing the code in the main.cpp with the example shown in SoQtRenderArea at http://doc.coin3d.org/SoQt/classSoQtRenderArea.html.

Pete

vonCZ
3rd May 2007, 15:17
The point of the zip file file was more to do with the managment of the compiler environment settings than the simple application itself.

oh, ok, thanks for that. I'm creating/opening Qt/Coin VS project files now, no problem.


If you want an example of how to embed a Coin3d window into an application, head over to http://sourceforge.net/projects/free-cad and grab the source fron the SVN trunk.

again, thanks. I downloaded the source and took a quick look: it's quite huge and difficult for me to follow--I'm completely new to Qt, Coin, and GUI programming in general--so I'll end with one last appeal: if anyone has a simple Qt app/demo which opens a SoQT/Coin window, please post.