MCPcopy Create free account
hub / github.com/XMuli/ChineseChess / mouseReleaseEvent

Method mouseReleaseEvent

ChessBoard.cpp:919–935  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

917}
918
919void ChessBoard::mouseReleaseEvent(QMouseEvent *ev)
920{
921 if (ev->button() != Qt::LeftButton || m_bIsOver== true) { // 排除鼠标右键点击 游戏已结束则直接返回
922 return;
923 }
924
925#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
926 const QPointF globalPos = ev->globalPosition();
927#else
928 const QPointF globalPos = ev->globalPos();
929#endif
930 const QPointF windowTopLeft = mapToGlobal(QPoint(0, 0));
931 const QPointF mousePos = globalPos - windowTopLeft; // 统一转换为 ChessBoard 坐标系
932
933 QPointF pt = getRealPoint(mousePos); // 转换为虚拟坐标
934 click(pt);
935}
936
937void ChessBoard::click(QPointF pt)
938{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected