I have added an customized QGraphicsPixmapItem to the Scene, but when I click on the item.. what can I say, it records it as a ordinary click on the scene, but if I click more than once very quickly, it also notice that the item is clicked.
(as a side note: if I click exactly in the left margin of the Item, it seems to respond to a slow single click.)
It's driving me crazy.
Here is code for the item
{
Qt::MouseButtons btn = ev->buttons();
if (btn & Qt::LeftButton)
{
qDebug()<<"You visited Lamerville";
}
}
void Town::mousePressEvent(QGraphicsSceneMouseEvent* ev)
{
Qt::MouseButtons btn = ev->buttons();
if (btn & Qt::LeftButton)
{
qDebug()<<"You visited Lamerville";
}
}
To copy to clipboard, switch view to plain text mode
When I set the position for the item, I set it with integer coordinats. but I think that can hardly be the problem.
Here is code for the scene
{
QPointF p
= ev
->buttonDownScenePos
( Qt
::LeftButton);
int x,y;
x=p.x()/SKAL;
y=p.y()/SKAL;
qDebug()<<"you pressed mouse on map"<<x<<y;
void Game::mousePressEvent(QGraphicsSceneMouseEvent* ev)
{
QPointF p = ev->buttonDownScenePos( Qt::LeftButton);
int x,y;
x=p.x()/SKAL;
y=p.y()/SKAL;
qDebug()<<"you pressed mouse on map"<<x<<y;
To copy to clipboard, switch view to plain text mode
SKAL is a constant for scaling purposes.
I'd be very happy for any suggestion. I guess there is a fundamental flaw... but what is it?
Bookmarks