Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    How to get the coordinates of the rect item under mouse position

    General and Desktop
    3
    5
    4628
    Loading More Posts
    • 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.
    • S
      sri438 last edited by

      hi,i have 15 rect items in my scene how can i find the rectitem coordinates under my mouse position on the scene...some one please help me

      1 Reply Last reply Reply Quote 0
      • A
        andre last edited by

        You really need to start writing more detailed opening posts. You will need to appreciate that the people reading your message know nothing of your project, your goals, or what classes or techniques you try to use.

        Please make it easy to reply to your questions by spending a bit more time in formulating them. Make sure they contain all the information somebody would need to give a sensible answer.

        Now, I will assume that you are using the graphics view framework, and your "scene" is a QGraphicsScene, and your "rect item" a "QGraphicsRectItem". If that is true, you should really look at the different QGraphicsView::items() methods that are available. They will return the information you need.

        1 Reply Last reply Reply Quote 0
        • S
          sri438 last edited by

          sorry , your assumption is correct but "QGraphicsView::items" will give all rectitems .. but i want only the co ordinates of rect item under the cursor position...

          1 Reply Last reply Reply Quote 0
          • A
            andre last edited by

            Please read the documentation for QGraphicsView::items(). There are overloads that do not return all items, but only a subset of them. I'll leave it to you to figure out which one to use. Once you have the item(s) under the cursor, it is easy to retreive the coordinates for those items under it.

            1 Reply Last reply Reply Quote 0
            • R
              rokemoon last edited by

              As Andre sayed you should read the documentation.
              You can use this one "items()":http://doc.qt.nokia.com/latest/qgraphicsscene.html#items-3

              1 Reply Last reply Reply Quote 0
              • First post
                Last post