From 30a62bc4ad39c341e1733c571f66c9f3a7212673 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 25 Feb 2015 19:19:37 +0000 Subject: [PATCH] From Jonathan Greig, "I was testing out the example and it works fine as a standalone example, but I found that it didn't work as expected when adding the class to some existing code I have to test it out. The osg widget was appearing but it didn't appear to be updating. After tweaking it to pass on the parent QWidget pointer from my code, it worked as expected. I added the WindowFlags to the attached file for good measure. If you look at the Qt Documentation for QWidget ( http://doc.qt.io/qt-5/qwidget.html#QWidget ), you'll see that is exactly where I got this from. When subclassing a widget as such, you should allow the user to pass in the parent at least, considering that has a major effect on how or if Qt may clean up the memory." git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14718 16af8721-9629-0410-8352-f15c8da7e697 --- examples/osgviewerQt/osgviewerQt.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/osgviewerQt/osgviewerQt.cpp b/examples/osgviewerQt/osgviewerQt.cpp index ee30256a9..e2e1f3fcc 100644 --- a/examples/osgviewerQt/osgviewerQt.cpp +++ b/examples/osgviewerQt/osgviewerQt.cpp @@ -16,7 +16,7 @@ class ViewerWidget : public QWidget, public osgViewer::CompositeViewer { public: - ViewerWidget(osgViewer::ViewerBase::ThreadingModel threadingModel=osgViewer::CompositeViewer::SingleThreaded) : QWidget() + ViewerWidget(QWidget* parent = 0, Qt::WindowFlags f = 0, osgViewer::ViewerBase::ThreadingModel threadingModel=osgViewer::CompositeViewer::SingleThreaded) : QWidget(parent, f) { setThreadingModel(threadingModel); @@ -106,7 +106,7 @@ int main( int argc, char** argv ) while (arguments.read("--CullThreadPerCameraDrawThreadPerContext")) threadingModel = osgViewer::ViewerBase::CullThreadPerCameraDrawThreadPerContext; QApplication app(argc, argv); - ViewerWidget* viewWidget = new ViewerWidget(threadingModel); + ViewerWidget* viewWidget = new ViewerWidget(0, Qt::Widget, threadingModel); viewWidget->setGeometry( 100, 100, 800, 600 ); viewWidget->show(); return app.exec();