[solved] graphicsView Mouse position and click.

  • Hi all.

    I am looking for a way that i can get the mouse position when clicked in a graphicsView.

    i tryed in the Dialog to add the @mousePressEvent(QGraphicsSceneMouseEvent *ev);@
    but that did not react to a mouse click.

    but when i use @mousePressEvent(QMouseEvent *ev);@ then it works but it wil retun the mouse position from the Dialog window and not only the graphicsView.

    I need some fresh ideas on how to get the X and Y from the graphicsView.

    Thanx in advanced.

  • Lifetime Qt Champion


    There's something unclear: What is your dialog doing ?

  • hi,

    ooow jhee sorry for that.

    i created a new Dialog project and then the mainwindow is changed in dialog.

    so it is the mainwindow whare the graphicsView is at.

  • Lifetime Qt Champion

    Do you mean that you open a dialog from your mainwindow ?

  • merry christmas,

    no i only have a dialog window in whith i put a graphicsView via the dialog.UI

    so the files that i have are.


    It is just a basic dialog project from QT creator.

  • Lifetime Qt Champion

    Same to you

    Then you have to subclass the QGraphicsView if you want to have that information from it or use an event filter.

  • Thanx a lot it helped me in the ride direction.

  • Lifetime Qt Champion

    You're welcome !

    Since you have your mouse events working correctly, please update the thread title prepending [solved] so other forum viewers may know a solution has been found :)

Log in to reply

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