diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2020-03-30 14:34:26 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2020-03-30 14:34:26 +0200 |
commit | 2879485212bbd97609b43f657fa3828922da774a (patch) | |
tree | d3fbb02036daa47b94d35aa81dfbeea95c298b76 | |
parent | 0bcdc74f55574e1a45bef8728bd5093cf1acfc33 (diff) | |
parent | 8ca337213f1e79abca96a70a17f771f322c58319 (diff) |
Merge remote-tracking branch 'origin/5.15' into dev
Change-Id: If239a0087c615b25a088eb60561ff7e019ea316c
-rw-r--r-- | examples/activeqt/opengl/doc/src/opengl.qdoc | 4 | ||||
-rw-r--r-- | examples/activeqt/opengl/glbox.cpp | 79 | ||||
-rw-r--r-- | examples/activeqt/opengl/glbox.h | 14 | ||||
-rw-r--r-- | examples/activeqt/opengl/main.cpp | 1 | ||||
-rw-r--r-- | examples/activeqt/opengl/opengl.pro | 2 | ||||
-rw-r--r-- | tools/testcon/invokemethod.cpp | 4 | ||||
-rw-r--r-- | tools/testcon/invokemethod.h | 2 |
7 files changed, 52 insertions, 54 deletions
diff --git a/examples/activeqt/opengl/doc/src/opengl.qdoc b/examples/activeqt/opengl/doc/src/opengl.qdoc index 5a4f8a3..000d864 100644 --- a/examples/activeqt/opengl/doc/src/opengl.qdoc +++ b/examples/activeqt/opengl/doc/src/opengl.qdoc @@ -82,14 +82,12 @@ \snippet activeqt/opengl/main.cpp 2 \snippet activeqt/opengl/main.cpp 3 - The \c GLBox class inherits from both the \l QGLWidget class to be able + The \c GLBox class inherits from both the \l QOpenGLWidget class to be able to render OpenGL, and from \l QAxBindable. \snippet activeqt/opengl/glbox.h 0 The class reimplements the \l QAxBindable::createAggregate() function from QAxBindable to return the pointer to a \l QAxAggregated object. \snippet activeqt/opengl/glbox.h 1 - The rest of the class declaration and the implementation of the OpenGL - rendering is identical to the original "box" example. The implementation file of the \c GLBox class includes the \c objsafe.h system header, in which the \c IObjectSafety COM interface is defined. diff --git a/examples/activeqt/opengl/glbox.cpp b/examples/activeqt/opengl/glbox.cpp index 6eef79d..3694bd8 100644 --- a/examples/activeqt/opengl/glbox.cpp +++ b/examples/activeqt/opengl/glbox.cpp @@ -64,20 +64,19 @@ #include <objsafe.h> //! [0] -#if defined(Q_CC_MSVC) -#pragma warning(disable:4305) // init: truncation from const double to float -#endif - /*! Create a GLBox widget */ GLBox::GLBox(QWidget *parent, const char *name) - : QGLWidget(parent) + : QOpenGLWidget(parent) { - m_xRot = m_yRot = m_zRot = 0.0; // default object rotation - m_scale = 1.25; // default object scale - m_object = 0; + setObjectName(name); + + QSurfaceFormat format; + format.setVersion(1, 1); + format.setProfile(QSurfaceFormat::CompatibilityProfile); + setFormat(format); } @@ -104,12 +103,12 @@ void GLBox::paintGL() glClear(GL_COLOR_BUFFER_BIT); glLoadIdentity(); - glTranslatef(0.0, 0.0, -10.0); - glScalef(m_scale, m_scale, m_scale); + glTranslated(0, 0, -10); + glScaled(m_scale, m_scale, m_scale); - glRotatef(m_xRot, 1.0, 0.0, 0.0); - glRotatef(m_yRot, 0.0, 1.0, 0.0); - glRotatef(m_zRot, 0.0, 0.0, 1.0); + glRotated(m_xRot, 1, 0, 0); + glRotated(m_yRot, 0, 1, 0); + glRotated(m_zRot, 0, 0, 1); glCallList(m_object); } @@ -122,8 +121,7 @@ void GLBox::paintGL() void GLBox::initializeGL() { initializeOpenGLFunctions(); - - qglClearColor(Qt::black); // Let OpenGL clear to black + glClearColor(0, 0, 0, 1); // Let OpenGL clear to black m_object = makeObject(); // Generate an OpenGL display list glShadeModel(GL_FLAT); } @@ -139,7 +137,7 @@ void GLBox::resizeGL(int w, int h) glViewport(0, 0, (GLint)w, (GLint)h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); - glFrustum(-1.0, 1.0, -1.0, 1.0, 5.0, 15.0); + glFrustum(-1, 1, -1, 1, 5, 15); glMatrixMode(GL_MODELVIEW); } @@ -156,29 +154,29 @@ GLuint GLBox::makeObject() glNewList(list, GL_COMPILE); - qglColor(Qt::white); // Shorthand for glColor3f or glIndex + glColor3d(1, 1, 1); // Shorthand for glColor3f or glIndex - glLineWidth(2.0); + glLineWidth(2); glBegin(GL_LINE_LOOP); - glVertex3f( 1.0, 0.5, -0.4); - glVertex3f( 1.0, -0.5, -0.4); - glVertex3f(-1.0, -0.5, -0.4); - glVertex3f(-1.0, 0.5, -0.4); + glVertex3d( 1, 0.5, -0.4); + glVertex3d( 1, -0.5, -0.4); + glVertex3d(-1, -0.5, -0.4); + glVertex3d(-1, 0.5, -0.4); glEnd(); glBegin(GL_LINE_LOOP); - glVertex3f( 1.0, 0.5, 0.4); - glVertex3f( 1.0, -0.5, 0.4); - glVertex3f(-1.0, -0.5, 0.4); - glVertex3f(-1.0, 0.5, 0.4); + glVertex3d( 1, 0.5, 0.4); + glVertex3d( 1, -0.5, 0.4); + glVertex3d(-1, -0.5, 0.4); + glVertex3d(-1, 0.5, 0.4); glEnd(); glBegin(GL_LINES); - glVertex3f( 1.0, 0.5, -0.4); glVertex3f( 1.0, 0.5, 0.4); - glVertex3f( 1.0, -0.5, -0.4); glVertex3f( 1.0, -0.5, 0.4); - glVertex3f(-1.0, -0.5, -0.4); glVertex3f(-1.0, -0.5, 0.4); - glVertex3f(-1.0, 0.5, -0.4); glVertex3f(-1.0, 0.5, 0.4); + glVertex3d( 1, 0.5, -0.4); glVertex3d( 1, 0.5, 0.4); + glVertex3d( 1, -0.5, -0.4); glVertex3d( 1, -0.5, 0.4); + glVertex3d(-1, -0.5, -0.4); glVertex3d(-1, -0.5, 0.4); + glVertex3d(-1, 0.5, -0.4); glVertex3d(-1, 0.5, 0.4); glEnd(); glEndList(); @@ -193,8 +191,8 @@ GLuint GLBox::makeObject() void GLBox::setXRotation(int degrees) { - m_xRot = (GLfloat)(degrees % 360); - updateGL(); + m_xRot = GLdouble(degrees % 360); + update(); } @@ -204,8 +202,8 @@ void GLBox::setXRotation(int degrees) void GLBox::setYRotation(int degrees) { - m_yRot = (GLfloat)(degrees % 360); - updateGL(); + m_yRot = GLdouble(degrees % 360); + update(); } @@ -215,8 +213,8 @@ void GLBox::setYRotation(int degrees) void GLBox::setZRotation(int degrees) { - m_zRot = (GLfloat)(degrees % 360); - updateGL(); + m_zRot = GLdouble(degrees % 360); + update(); } //! [1] @@ -230,11 +228,10 @@ public: long queryInterface(const QUuid &iid, void **iface) override { *iface = nullptr; - if (iid == IID_IObjectSafety) - *iface = (IObjectSafety*)this; - else + if (iid != IID_IObjectSafety) return E_NOINTERFACE; + *iface = static_cast<IObjectSafety*>(this); AddRef(); return S_OK; } @@ -245,6 +242,7 @@ public: //! [3] //! [4] HRESULT WINAPI GetInterfaceSafetyOptions(REFIID riid, DWORD *pdwSupportedOptions, DWORD *pdwEnabledOptions) override { + Q_UNUSED(riid); *pdwSupportedOptions = INTERFACESAFE_FOR_UNTRUSTED_DATA | INTERFACESAFE_FOR_UNTRUSTED_CALLER; *pdwEnabledOptions = INTERFACESAFE_FOR_UNTRUSTED_DATA | INTERFACESAFE_FOR_UNTRUSTED_CALLER; return S_OK; @@ -252,6 +250,9 @@ public: HRESULT WINAPI SetInterfaceSafetyOptions(REFIID riid, DWORD pdwSupportedOptions, DWORD pdwEnabledOptions) override { + Q_UNUSED(riid); + Q_UNUSED(pdwSupportedOptions); + Q_UNUSED(pdwEnabledOptions); return S_OK; } }; diff --git a/examples/activeqt/opengl/glbox.h b/examples/activeqt/opengl/glbox.h index b1bd828..6197b3a 100644 --- a/examples/activeqt/opengl/glbox.h +++ b/examples/activeqt/opengl/glbox.h @@ -57,12 +57,12 @@ #ifndef GLBOX_H #define GLBOX_H -#include <QtOpenGL> +#include <QOpenGLWidget> #include <QOpenGLFunctions_1_1> //! [0] #include <QAxBindable> -class GLBox : public QGLWidget, +class GLBox : public QOpenGLWidget, public QOpenGLFunctions_1_1, public QAxBindable { @@ -90,11 +90,11 @@ protected: virtual GLuint makeObject(); private: - GLuint m_object; - GLfloat m_xRot; - GLfloat m_yRot; - GLfloat m_zRot; - GLfloat m_scale; + GLuint m_object = 0; + GLdouble m_xRot = 0; + GLdouble m_yRot = 0; + GLdouble m_zRot = 0; + GLdouble m_scale = 1.25; }; #endif // GLBOX_H diff --git a/examples/activeqt/opengl/main.cpp b/examples/activeqt/opengl/main.cpp index 94cbf27..a3de04b 100644 --- a/examples/activeqt/opengl/main.cpp +++ b/examples/activeqt/opengl/main.cpp @@ -60,7 +60,6 @@ #include "globjwin.h" #include "glbox.h" #include <QApplication> -#include <QtOpenGL> //! [0] #include <QAxFactory> diff --git a/examples/activeqt/opengl/opengl.pro b/examples/activeqt/opengl/opengl.pro index d3e44c4..c62f700 100644 --- a/examples/activeqt/opengl/opengl.pro +++ b/examples/activeqt/opengl/opengl.pro @@ -2,7 +2,7 @@ TEMPLATE = app TARGET = openglax CONFIG += warn_off -QT += widgets axserver opengl +QT += widgets axserver HEADERS = glbox.h \ globjwin.h diff --git a/tools/testcon/invokemethod.cpp b/tools/testcon/invokemethod.cpp index 2c30705..48dfabb 100644 --- a/tools/testcon/invokemethod.cpp +++ b/tools/testcon/invokemethod.cpp @@ -75,7 +75,7 @@ void InvokeMethod::setControl(QAxBase *ax) } comboMethods->model()->sort(0); - on_comboMethods_activated(comboMethods->currentText()); + on_comboMethods_textActivated(comboMethods->currentText()); } } @@ -105,7 +105,7 @@ void InvokeMethod::on_buttonInvoke_clicked() + QLatin1Char(' ') + result.toString()); } -void InvokeMethod::on_comboMethods_activated(const QString &method) +void InvokeMethod::on_comboMethods_textActivated(const QString &method) { if (!activex) return; diff --git a/tools/testcon/invokemethod.h b/tools/testcon/invokemethod.h index 3fb3ddf..dff8cc9 100644 --- a/tools/testcon/invokemethod.h +++ b/tools/testcon/invokemethod.h @@ -48,7 +48,7 @@ protected slots: void on_buttonInvoke_clicked(); void on_buttonSet_clicked(); - void on_comboMethods_activated(const QString &method); + void on_comboMethods_textActivated(const QString &method); void on_listParameters_currentItemChanged(QTreeWidgetItem *item); private: |