QGraphicsItem mousepressevent not working with QMessageBox?

  • This is a really bizarre problem I am having. So, I have my custom QGraphicsItem. In that, I have MousePressEvent.

    @void myGraphicsItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
    engine->whatWasPressed(QString name_);

    Engine is another class and the name stands for the name of the QGraphicsItem. In the whatWasPressed function, I try setting up qDebug to see what was clicked. Fair enough, everything works. But then when I try calling for a QMessageBox in said function, everything seems to break. When I press another object again, it recognizes as if I had pressed the object that launched the QMessageBox. So, mousepressevent works when I simply debug the answers out, but if I call a QMessageBox, it doesn't work. I can only think of this being related to QMessagebox messing up the mousepressevent, since the message box is called kinda in the middle of the event, as the message box requires the user to press OK. So I have no idea how I could fix this. Any help?

    Edit: To clarify, I have four objects named triangle, square, line and circle. When I just check the names with qdebug, everything works. When I press circle, qdebug says circle. However if I set a message box, then the message box displays what I click, for instance square, but if I click anything after that, it still says I clicked square. Even the debugger says I click square after the message box has appeared once.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.