Important: Please read the Qt Code of Conduct -

[Solved] Strange problem with QGraphicsScene and a popup QDialog

  • Hi, i create a QGraphicScene that have 3 object inside. This object is Service, the service is derived from PixmapItemAnimation, a simple QGraphicsPixmapItem with some animation. I want click on the Service object and open a QDialog.
    I use signal mousePressEvent from Service and connect to a slot servicePressed() on Home class. In the slot i use a qDebug() << id_service, to know what Service object is pressed. If i try click on it i correctly receive the id_service of the object. But if i open a QDialog and close. After a click on every zone of QGraphicScene generate a signal mousePressEvent with the latest id_service that have open the QDialog!!! It's incredible!
    If you have time look the source code... try this:
    1)click on object1 get a normal id_service 1
    2)click object2 you get a QDialog...
    3) click on object1 or every zone of get the previous QDialog!

    Someone can help me from this issue?

    this is the "zip file":

  • Hi!

    Looks like event is not processed correctly.

    If you change to:
    @void Service::mousePressEvent(QGraphicsSceneMouseEvent *event)
    emit buttonPressed(id_service);


    It'll work.


  • Thank's you Jake007 now works perfect!

Log in to reply