Skip to content

Commit 96ca76c

Browse files
committed
Fix the CI with Qt5
1 parent be8520f commit 96ca76c

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

examples/openGL/glwidget.cpp

+13-3
Original file line numberDiff line numberDiff line change
@@ -242,13 +242,23 @@ void GLWidget::resizeGL(int w, int h)
242242

243243
void GLWidget::mousePressEvent(QMouseEvent *event)
244244
{
245+
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
245246
m_lastPos = event->position().toPoint();
247+
#else
248+
m_lastPos = event->pos().toPoint();
249+
#endif
246250
}
247251

248252
void GLWidget::mouseMoveEvent(QMouseEvent *event)
249253
{
250-
int dx = event->position().toPoint().x() - m_lastPos.x();
251-
int dy = event->position().toPoint().y() - m_lastPos.y();
254+
255+
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
256+
QPoint pos = event->position().toPoint();
257+
#else
258+
QPoint pos = event->pos().toPoint();
259+
#endif
260+
int dx = pos.x() - m_lastPos.x();
261+
int dy = pos.y() - m_lastPos.y();
252262

253263
if (event->buttons() & Qt::LeftButton) {
254264
setXRotation(m_xRot + 8 * dy);
@@ -257,5 +267,5 @@ void GLWidget::mouseMoveEvent(QMouseEvent *event)
257267
setXRotation(m_xRot + 8 * dy);
258268
setZRotation(m_zRot + 8 * dx);
259269
}
260-
m_lastPos = event->position().toPoint();
270+
m_lastPos = pos;
261271
}

examples/openGL/logo.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
#define LOGO_H
66

77
#include <qopengl.h>
8-
#include <QList>
8+
#include <vector>
99
#include <QVector3D>
1010

1111
class Logo
1212
{
1313
public:
1414
Logo();
15-
const GLfloat *constData() const { return m_data.constData(); }
15+
const GLfloat *constData() const { return m_data.data(); }
1616
int count() const { return m_count; }
1717
int vertexCount() const { return m_count / 6; }
1818

@@ -21,7 +21,7 @@ class Logo
2121
void extrude(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2);
2222
void add(const QVector3D &v, const QVector3D &n);
2323

24-
QList<GLfloat> m_data;
24+
std::vector<GLfloat> m_data;
2525
int m_count = 0;
2626
};
2727

examples/openGL/main.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
int main(int argc, char* argv[])
1414
{
1515
// https://doc.qt.io/qt-6/qtdatavisualization-known-issues.html
16-
// Use either `qputenv("QSG_RHI_BACKEND", "opengl");` or the following line
17-
QQuickWindow::setGraphicsApi(QSGRendererInterface::OpenGL);
16+
// Use either `QQuickWindow::setGraphicsApi(QSGRendererInterface::OpenGL);` or the following line
17+
qputenv("QSG_RHI_BACKEND", "opengl");
1818

1919
// Disable warnings when attempts are made to convert non-convertible non-native widgets
2020
// to native widgets (such as QQuickWidget)

0 commit comments

Comments
 (0)