It works, thank you, Emeric! peng
On Wed, May 21, 2014 at 1:09 AM, Émeric MASCHINO <[email protected]>wrote: > Hi, > > Have a look at Wang Rui's excellent osgRecipes repository, more > particularly osg_qt example: > > https://github.com/xarray/osgRecipes/blob/master/cookbook/chapter9/ch09_01/osg_qt.cpp > > There was an error where a new camera was incorrectly created rather > than retrieved from the viewer. This has been fixed in the above > provided URL. > > Hope this helps, > > Émeric > > 2014-05-20 18:11 GMT+02:00 sunpeng <[email protected]>: > > I've read examples/osgviewerQt, and written codes: > > > > int main(int argc, char *argv[]) > > > > { > > > > QApplication a(argc, argv); > > > > > > > > Window window1; > > > > > > osgViewer::Viewer* viewer = new osgViewer::Viewer(); > > osg::Group* root = new osg::Group(); > > osg::Node* node = new osg::Node(); > > node = osgDB::readNodeFile("cow.osg"); > > root->addChild(node); > > osgUtil::Optimizer optimizer ; > > optimizer.optimize(root) ; > > viewer->setSceneData(root); > > viewer->setCamera(new osg::Camera()); > > osg::Camera* camera = viewer->getCamera(); > > osgQt::GraphicsWindowQt* gw = dynamic_cast<osgQt::GraphicsWindowQt*>( > > camera->getGraphicsContext() ); > > osgQt::GLWidget* widget1 = gw ? gw->getGLWidget() : NULL; > > widget1->setGeometry( 100, 100, 800, 600 ); > > QGridLayout* grid = new QGridLayout(); > > grid->addWidget( widget1, 0, 0 ); > > window1.setLayout(grid); > > > > viewer->realize(); > > > > window1.show(); > > return a.exec(); > > } > > > > but it seems > > gw is null, i just want create osg widget( such as > osgQt::GraphicsWindowQ ), > > and integrate into QT, how to write codes? > > > > Thanks! > > > > peng > > > > > > > > _______________________________________________ > > osg-users mailing list > > [email protected] > > > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > > > _______________________________________________ > osg-users mailing list > [email protected] > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org >
_______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

