Skip to content

Commit 78b4fed

Browse files
committed
Coding - suppress Qt 6.4.2 deprecation warnings
1 parent 61a34fe commit 78b4fed

1 file changed

Lines changed: 37 additions & 2 deletions

File tree

occt-qt-tools/OcctQtTools.cpp

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,11 @@ bool OcctQtTools::qtHandleHoverEvent(Aspect_WindowInputListener& theListener,
147147
const Handle(V3d_View)& theView,
148148
const QHoverEvent* theEvent)
149149
{
150-
const Graphic3d_Vec2d aPnt2d(theEvent->pos().x(), theEvent->pos().y());
150+
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
151+
const Graphic3d_Vec2d aPnt2d(theEvent->position().x(), theEvent->position().y());
152+
#else
153+
const Graphic3d_Vec2d aPnt2d(theEvent->pos().x(), theEvent->pos().y());
154+
#endif
151155
const Graphic3d_Vec2i aPnt2i(theView->Window()->ConvertPointToBacking(aPnt2d) + Graphic3d_Vec2d(0.5));
152156
const Aspect_VKeyMouse aButtons = Aspect_VKeyMouse_NONE;
153157
const Aspect_VKeyFlags aFlags = OcctQtTools::qtMouseModifiers2VKeys(theEvent->modifiers());
@@ -161,7 +165,11 @@ bool OcctQtTools::qtHandleMouseEvent(Aspect_WindowInputListener& theListener,
161165
const Handle(V3d_View)& theView,
162166
const QMouseEvent* theEvent)
163167
{
164-
const Graphic3d_Vec2d aPnt2d(theEvent->pos().x(), theEvent->pos().y());
168+
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
169+
const Graphic3d_Vec2d aPnt2d(theEvent->position().x(), theEvent->position().y());
170+
#else
171+
const Graphic3d_Vec2d aPnt2d(theEvent->pos().x(), theEvent->pos().y());
172+
#endif
165173
const Graphic3d_Vec2i aPnt2i(theView->Window()->ConvertPointToBacking(aPnt2d) + Graphic3d_Vec2d(0.5));
166174
const Aspect_VKeyMouse aButtons = OcctQtTools::qtMouseButtons2VKeys(theEvent->buttons());
167175
const Aspect_VKeyFlags aFlags = OcctQtTools::qtMouseModifiers2VKeys(theEvent->modifiers());
@@ -195,6 +203,32 @@ bool OcctQtTools::qtHandleTouchEvent(Aspect_WindowInputListener& theListener,
195203
const QTouchEvent* theEvent)
196204
{
197205
bool hasUpdates = false;
206+
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
207+
for (const QTouchEvent::TouchPoint& aQTouch : theEvent->points())
208+
{
209+
const Standard_Size aTouchId = aQTouch.id();
210+
const Graphic3d_Vec2d aNewPos2d =
211+
theView->Window()->ConvertPointToBacking(Graphic3d_Vec2d(aQTouch.position().x(), aQTouch.position().y()));
212+
const Graphic3d_Vec2i aNewPos2i = Graphic3d_Vec2i(aNewPos2d + Graphic3d_Vec2d(0.5));
213+
if (aQTouch.state() == QEventPoint::Pressed
214+
&& aNewPos2i.minComp() >= 0)
215+
{
216+
hasUpdates = true;
217+
theListener.AddTouchPoint(aTouchId, aNewPos2d);
218+
}
219+
else if (aQTouch.state() == QEventPoint::Updated
220+
&& theListener.TouchPoints().Contains(aTouchId))
221+
{
222+
hasUpdates = true;
223+
theListener.UpdateTouchPoint(aTouchId, aNewPos2d);
224+
}
225+
else if (aQTouch.state() == QEventPoint::Released
226+
&& theListener.RemoveTouchPoint(aTouchId))
227+
{
228+
hasUpdates = true;
229+
}
230+
}
231+
#else
198232
for (const QTouchEvent::TouchPoint& aQTouch : theEvent->touchPoints())
199233
{
200234
const Standard_Size aTouchId = aQTouch.id();
@@ -219,6 +253,7 @@ bool OcctQtTools::qtHandleTouchEvent(Aspect_WindowInputListener& theListener,
219253
hasUpdates = true;
220254
}
221255
}
256+
#endif
222257
return hasUpdates;
223258
}
224259

0 commit comments

Comments
 (0)