简体   繁体   English

在Qt C ++中通过mouseEvent单击获取对象

[英]Get object clicked by mouseEvent in Qt C++

I have a scene made up of objects, each with a different position. 我有一个由物体组成的场景,每个物体都有不同的位置。 I also have 2–4 pawns I'd like to move to the position of the object clicked, not to the position of the event. 我还有2-4个棋子,我想移动到被点击的对象的位置,而不是事件的位置。

I tried doing something like event->pos() but that gives me the coordinates of the event. 我尝试过像event->pos()这样的东西,但它给了我事件的坐标。 Is there any way to do this? 有没有办法做到这一点?

您正在寻找的方法是QGraphicsView :: items()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM