H3D.org Forum Index Installing and compiling
Using QT with H3D? | Register To Post |
| Threaded | Newest First | Previous Topic | Next Topic | Bottom |
| Poster | Thread |
|---|---|
| xhanley | Posted on: 2010/1/6 14:45 |
Quite a regular ![]() ![]() Joined: 2009/7/24 From: Posts: 22 |
Using QT with H3D? Hi,
I am trying to develop a H3D program written mainly in C++ which uses QT for its GUI. I am using H3D 2.1 and VC++ 2008 to compile. I have got the QTexample Daniel developed and have been updating the paths etc. What will be the main issues that we will have to overcome to get this working? Is it a good template for a general H3D project or is there another route to using QT? Thanks for your time.
|
| arettig | Posted on: 2010/1/19 14:17 |
Not too shy to talk ![]() ![]() Joined: 2006/2/18 From: Posts: 13 |
Re: Using QT with H3D? Hi Donnchadh,
we did some development for integrating H3D with Qt. It's currently on hold, so the integration is not up to date with the current H3D. My answer now will be a little cursory but hopefully helps already. We started from the QTExample from Daniel but tried out several approaches. The issues you may have to deal with are: 1) Defining the interface between H3D and QtGLWidget for rendering 2) Communication between 2D GUI and 3D scene: linking Qt's signal and slot system to the X3D/H3D fields and routes system 3) probably context sharing / multi window setup 1) Our approach was to create two interfaces and link them together: - the H3DWidget derived from QtGLWidget - quasi the Qt view on the H3D scene providing the Qt like interface. It implements the Qt methods necessary to allow H3D to render in the Qt application. - the QtWindow derived from H3DWindow, which creates the interface to Qt from the view of H3D. It is e.g. responsible for mapping e.g. the user mouse input from Qt events created within the H3DWidget to the H3D system (in analogy e.g. to the GLUTWindow) Another approach would be to use multiple inheritance and derive from both QtGLWidget and H3DWindow. 2) The fields and routes system of X3D in a way provides a subset of the functionality of the Qt signal and slot system. Our Idea now was to create QtField classes like QtSFFloat, QtMFVec3d which map received X3D events to Qt signals and vice versa. The concept works but is tedious to implement, since Qt (especially the MOC) doesn't harmonize well with C++ templates and template meta programming, which is used extensively in H3D to generate the different field types. We got manual implementations of some QtFields working but the next step would be to write a generator (python) script to automate this. 3) If you want to have several windows in one application showing diffent views into the same scene, some additional work has to be done. For better performance GL context sharing would be good, see http://www.h3dapi.org/modules/newbb/viewtopic.php?topic_id=838&forum=4 . We got something working using QtGLWidget features, but this was on Qt 4.3 and H3D pre 2.0, so it might be different/easier now. The other point was that we didn't find it too easy to instantiate several QtWindows and link them to different viewpoints independently. To ease this maybe some changes inside the viewpoint/window handling in H3D would help, but my knowledge about this part of H3D may be outdated. So I hope this helps for the first. Alex |
| GBaitson | Posted on: 2010/2/26 15:26 |
Quite a regular ![]() ![]() Joined: 2009/5/19 From: National Digital Research Centre Posts: 25 |
Re: Using QT with H3D? Hi Alex,
We have Qt integrated with H3D at the moment. We are now trying to work on catching events. Even the simplest form of keysensor or mousesensor doesn't seem to be working. We firstly tried the H3D update way of catching events, but it doesn't even seem to go into the update function at all (it doesn't seem to know that a key has been pressed: We then tried the way in which Qt handles events. Which is the create a class which handles the event. But neither of these seem to work. They compile and run fine, but still the key press is not being caught. In the second one, how exactly do we instantiate the KeyPressed class and wait for the event? Is this why nothing happens? Have you any pointers on which way to catch a key or mouse event? Any help would be great |
| Markus | Posted on: 2010/3/3 16:32 |
Webmaster ![]() ![]() Joined: 2006/3/27 From: SenseGraphics Posts: 1531 |
Re: Using QT with H3D? Hello, I can probably give some pointer on what might be wrong with Key/MouseSensor in H3DAPI.
Are you using Windows? If not, then in your class that inherits from H3DWindowNode does it ever call some functions that has to do with key events? If not then that is probably why KeySensor and MouseSensor nodes in H3DAPI are not working properly. For an example of this see wxWidgetsWindow that comes with H3DViewer. Another reason could be that the window for some reason never has focus. If the H3DWindowNode does not have focus then I think that Windows specific key handling will not work properly. |
| Threaded | Newest First | Previous Topic | Next Topic | Top |
| Register To Post | |




