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
This commit is contained in:
parent
47db2da8b4
commit
30a62bc4ad
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user