QDropEvent::pos() is deprecated since 6.0.

This commit is contained in:
Roman Telezhynskyi 2023-02-09 16:13:18 +02:00
parent 10c6ff1181
commit 885a618820
3 changed files with 14 additions and 2 deletions

View File

@ -205,7 +205,7 @@ void VPMainGraphicsView::dropEvent(QDropEvent *event)
event->acceptProposedAction();
piece->ClearTransformations();
piece->SetPosition(mapToScene(event->pos()));
piece->SetPosition(mapToScene(DropEventPos(event)));
piece->SetZValue(1.0);
auto *command = new VPUndoMovePieceOnSheet(layout->GetFocusedSheet(), piece);

View File

@ -318,4 +318,15 @@ inline auto VLocaleCharacter(const QChar &character) -> QChar
{
return character;
}
//---------------------------------------------------------------------------------------------------------------------
inline auto DropEventPos(const QDropEvent *event) -> QPoint
{
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
return event->position().toPoint();
#else
return event->pos();
#endif
}
#endif // COMPATIBILITY_H

View File

@ -60,6 +60,7 @@
#include "../vmisc/vabstractapplication.h"
#include "../vmisc/vcommonsettings.h"
#include "../vmisc/literals.h"
#include "../vmisc/compatibility.h"
#include "global.h"
#include "../ifc/xml/utils.h"
@ -711,7 +712,7 @@ void VMainGraphicsView::dropEvent(QDropEvent *event)
QFileInfo f(fileName);
if (f.exists() && IsMimeTypeImage(QMimeDatabase().mimeTypeForFile(fileName)))
{
emit currentScene->AddBackgroundImage(mapToScene(event->pos()), fileName);
emit currentScene->AddBackgroundImage(mapToScene(DropEventPos(event)), fileName);
event->acceptProposedAction();
}
}