diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-07-11 15:12:56 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-10-17 09:16:01 +0000 |
commit | 0ead3b7142e47b89059af689de4ede47075375be (patch) | |
tree | de3c43993ccbc1d65ad304ef82eb3f430a0dd587 /examples/widgets/painting/shared/arthurwidgets.h | |
parent | 16ebc78ef3280bf284da9a49bdd3fc1fabad347f (diff) |
Move arthurwidget based examples to new QOpenGL classes
Several of the examples were not even working besides using deprecated
classes.
Change-Id: I352e0629d490593edcc5868d2ec5a8ff222eaeab
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'examples/widgets/painting/shared/arthurwidgets.h')
-rw-r--r-- | examples/widgets/painting/shared/arthurwidgets.h | 46 |
1 files changed, 9 insertions, 37 deletions
diff --git a/examples/widgets/painting/shared/arthurwidgets.h b/examples/widgets/painting/shared/arthurwidgets.h index d6e1e44b3a..73e1310c0e 100644 --- a/examples/widgets/painting/shared/arthurwidgets.h +++ b/examples/widgets/painting/shared/arthurwidgets.h @@ -56,42 +56,13 @@ #include <QPushButton> #include <QGroupBox> -#if defined(QT_OPENGL_SUPPORT) -#include <QGLWidget> -#include <QEvent> -class GLWidget : public QGLWidget -{ -public: - GLWidget(QWidget *parent) - : QGLWidget(QGLFormat(QGL::SampleBuffers), parent) - { - setAttribute(Qt::WA_AcceptTouchEvents); - } - void disableAutoBufferSwap() { setAutoBufferSwap(false); } - void paintEvent(QPaintEvent *) override { parentWidget()->update(); } -protected: - bool event(QEvent *event) override - { - switch (event->type()) { - case QEvent::TouchBegin: - case QEvent::TouchUpdate: - case QEvent::TouchEnd: - event->ignore(); - return false; - break; - default: - break; - } - return QGLWidget::event(event); - } -}; -#endif - +QT_FORWARD_DECLARE_CLASS(QOpenGLWindow) QT_FORWARD_DECLARE_CLASS(QTextDocument) QT_FORWARD_DECLARE_CLASS(QTextEdit) QT_FORWARD_DECLARE_CLASS(QVBoxLayout) class ArthurFrame : public QWidget + { Q_OBJECT public: @@ -107,9 +78,8 @@ public: void loadSourceFile(const QString &fileName); bool preferImage() const { return m_prefer_image; } - -#if defined(QT_OPENGL_SUPPORT) - QGLWidget *glWidget() const { return glw; } +#if QT_CONFIG(opengl) + QOpenGLWindow *glWindow() const { return m_glWindow; } #endif public slots: @@ -117,7 +87,7 @@ public slots: void setDescriptionEnabled(bool enabled); void showSource(); -#if defined(QT_OPENGL_SUPPORT) +#if QT_CONFIG(opengl) void enableOpenGL(bool use_opengl); bool usesOpenGL() { return m_use_opengl; } #endif @@ -129,8 +99,10 @@ protected: void paintEvent(QPaintEvent *) override; void resizeEvent(QResizeEvent *) override; -#if defined(QT_OPENGL_SUPPORT) - GLWidget *glw; +#if QT_CONFIG(opengl) + virtual void createGlWindow(); + QOpenGLWindow *m_glWindow; + QWidget *m_glWidget; bool m_use_opengl; #endif QPixmap m_tile; |