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. How to get the coordinates of the rect item under mouse position
QtWS25 Last Chance

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

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 5.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.
  • S Offline
    S Offline
    sri438
    wrote on last edited by
    #1

    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
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      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
      0
      • S Offline
        S Offline
        sri438
        wrote on last edited by
        #3

        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
        0
        • A Offline
          A Offline
          andre
          wrote on last edited by
          #4

          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
          0
          • R Offline
            R Offline
            rokemoon
            wrote on last edited by
            #5

            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
            0

            • Login

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