diff --git a/MainWindow.cpp b/MainWindow.cpp index 46d82fa..5b633a9 100644 --- a/MainWindow.cpp +++ b/MainWindow.cpp @@ -2,6 +2,7 @@ #include "OSGWidget.h" #include +#include #include MainWindow::MainWindow( QWidget* parent, Qt::WindowFlags flags ) diff --git a/OSGWidget.cpp b/OSGWidget.cpp index 9acbcac..62f6752 100644 --- a/OSGWidget.cpp +++ b/OSGWidget.cpp @@ -28,6 +28,7 @@ #include #include +#include #include namespace @@ -67,11 +68,9 @@ QRect makeRectangle( const QPoint& first, const QPoint& second ) } OSGWidget::OSGWidget( QWidget* parent, - const QGLWidget* shareWidget, Qt::WindowFlags f ) - : QGLWidget( parent, - shareWidget, - f ) + : QOpenGLWidget( parent, + f ) , graphicsWindow_( new osgViewer::GraphicsWindowEmbedded( this->x(), this->y(), this->width(), @@ -140,8 +139,6 @@ OSGWidget::OSGWidget( QWidget* parent, viewer_->setThreadingModel( osgViewer::CompositeViewer::SingleThreaded ); viewer_->realize(); - this->setAutoBufferSwap( false ); - // This ensures that the widget will receive keyboard events. This focus // policy is not set by default. The default, Qt::NoFocus, will result in // keyboard events that are ignored. @@ -178,7 +175,6 @@ void OSGWidget::paintEvent( QPaintEvent* /* paintEvent */ ) painter.end(); - this->swapBuffers(); this->doneCurrent(); } @@ -359,7 +355,7 @@ void OSGWidget::wheelEvent( QWheelEvent* event ) bool OSGWidget::event( QEvent* event ) { - bool handled = QGLWidget::event( event ); + bool handled = QOpenGLWidget::event( event ); // This ensures that the OSG widget is always going to be repainted after the // user performed some interaction. Doing this in the event handler ensures diff --git a/OSGWidget.h b/OSGWidget.h index ae6a4ba..9344e08 100644 --- a/OSGWidget.h +++ b/OSGWidget.h @@ -2,20 +2,19 @@ #define OSGWidget_h__ #include -#include +#include #include #include #include -class OSGWidget : public QGLWidget +class OSGWidget : public QOpenGLWidget { Q_OBJECT public: OSGWidget( QWidget* parent = 0, - const QGLWidget* shareWidget = 0, Qt::WindowFlags f = 0 ); virtual ~OSGWidget();