Quantcast
Channel: Jobs
Viewing all articles
Browse latest Browse all 18427

How to get the mouse click coordinate in a scene?

$
0
0
Hi.. I make some circle in one scene using QGraphicsEllipseItem. I want to grab a real coordinate (not the center of the circle) of this item when someone left-clicked every circle. Using the first code it can only detect the coordinate when I clicked outside of the circle but when I clicked inside of every circle, the coordinate not shown. void DialogApplication::mousePressEvent(QMouseEvent *event) {     if (event->button()==Qt::LeftButton){         mouse_koordinat=event->pos();             qDebug() << "coordinate in my item: " << mouse_koordinat.x();     } } Using this second code there is an error message: “overloaded member function not found in ‘DialogApplication’ “ void DialogApplication::mousePressEvent(QGraphicsSceneMouseEvent *event)   //QMouseEvent *event) // {     if (event->button()==Qt::LeftButton){           mouse_koordinat=event->buttonDownScenePos(Qt::LeftButton);           qDebug() << "coordinate in my item: " << mouse_koordinat.x();     } } I appreciate if there is a suggestion and help. Thank you…

Viewing all articles
Browse latest Browse all 18427

Trending Articles