Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [solved] graphicsView Mouse position and click.

[solved] graphicsView Mouse position and click.

Scheduled Pinned Locked Moved General and Desktop
8 Posts 2 Posters 2.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Ducky
    wrote on last edited by
    #1

    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.

    Well I used to write code in Autoit and work on Windows.
    And now i am trying to write code in QT and work on Ubuntu

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

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

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • D Offline
        D Offline
        Ducky
        wrote on last edited by
        #3

        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.

        Well I used to write code in Autoit and work on Windows.
        And now i am trying to write code in QT and work on Ubuntu

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

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

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • D Offline
            D Offline
            Ducky
            wrote on last edited by
            #5

            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.

            dialog.cpp
            main.cpp
            dialog.h
            dialog.ui

            It is just a basic dialog project from QT creator.

            Well I used to write code in Autoit and work on Windows.
            And now i am trying to write code in QT and work on Ubuntu

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Same to you

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

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • D Offline
                D Offline
                Ducky
                wrote on last edited by
                #7

                Thanx a lot it helped me in the ride direction.

                Well I used to write code in Autoit and work on Windows.
                And now i am trying to write code in QT and work on Ubuntu

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  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 :)

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved