File tree 3 files changed +18
-8
lines changed
3 files changed +18
-8
lines changed Original file line number Diff line number Diff line change @@ -242,13 +242,23 @@ void GLWidget::resizeGL(int w, int h)
242
242
243
243
void GLWidget::mousePressEvent (QMouseEvent *event)
244
244
{
245
+ #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
245
246
m_lastPos = event->position ().toPoint ();
247
+ #else
248
+ m_lastPos = event->pos ().toPoint ();
249
+ #endif
246
250
}
247
251
248
252
void GLWidget::mouseMoveEvent (QMouseEvent *event)
249
253
{
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 ();
252
262
253
263
if (event->buttons () & Qt::LeftButton) {
254
264
setXRotation (m_xRot + 8 * dy);
@@ -257,5 +267,5 @@ void GLWidget::mouseMoveEvent(QMouseEvent *event)
257
267
setXRotation (m_xRot + 8 * dy);
258
268
setZRotation (m_zRot + 8 * dx);
259
269
}
260
- m_lastPos = event-> position (). toPoint () ;
270
+ m_lastPos = pos ;
261
271
}
Original file line number Diff line number Diff line change 5
5
#define LOGO_H
6
6
7
7
#include < qopengl.h>
8
- #include < QList >
8
+ #include < vector >
9
9
#include < QVector3D>
10
10
11
11
class Logo
12
12
{
13
13
public:
14
14
Logo ();
15
- const GLfloat *constData () const { return m_data.constData (); }
15
+ const GLfloat *constData () const { return m_data.data (); }
16
16
int count () const { return m_count; }
17
17
int vertexCount () const { return m_count / 6 ; }
18
18
@@ -21,7 +21,7 @@ class Logo
21
21
void extrude (GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2);
22
22
void add (const QVector3D &v, const QVector3D &n);
23
23
24
- QList <GLfloat> m_data;
24
+ std::vector <GLfloat> m_data;
25
25
int m_count = 0 ;
26
26
};
27
27
Original file line number Diff line number Diff line change 13
13
int main (int argc, char * argv[])
14
14
{
15
15
// 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 " );
18
18
19
19
// Disable warnings when attempts are made to convert non-convertible non-native widgets
20
20
// to native widgets (such as QQuickWidget)
You can’t perform that action at this time.
0 commit comments