Qt World Summit: Register Today!

Qt 5.4 and OpenSceneGraph

  • Hi everyone,
    I am using Qt5.4 in combination with OpenSceneGraph 3.2.

    What I want is to use Qt as the Windowing System. There is also an example under: https://github.com/xarray/osgRecipes/blob/master/cookbook/chapter9/ch09_01/osg_qt.cpp

    I used this and it is working quite well. I have my OpenSceneGraph Scene rendered in a QtWidget:

     osgQt::GraphicsWindowQt* gw = createGraphicsWindow( 50, 50, 640, 480 );
     //osg::Node* scene = osgDB::readNodeFile("cow.osg");
     osg::Node* scene = root;
    ViewerWidget* widgetOSG = new ViewerWidget(gw, scene);
    widgetOSG->setGeometry( 100, 100, 800, 600 );

    In my code I used my root node which holds an animated 3d robot. This is working fine.

    My problem now is that I want to use the QWidget inside a MainWindow and I just don´t get this to work.
    The code I am using right now is;


    The whole code I posted is in my sourceFile from the MainWindow.cpp . I just used the standard MainWindow that
    Qt Creator is creating when a new Qt Project is set up. widgetOSG is just a QWidget I created in the forms editor.

    It looks like the scene is loaded into that QWidget. But I can´t see it.
    One thing the compiler says is:

    QWindowsWindow::setGeometryDp: Unable to set geometry 22x22+640+280 on QWidgetWindow/'QWidgetClassWindow'. Resulting geometry:  124x22+640+280 (frame: 8, 31, 8, 8, custom margin: 0, 0, 0, 0, minimum size: 22x22, maximum size: 16777215x16777215).

    I appreciate any help.


Log in to reply