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 use QGraphicsScene::itemAt ?

How use QGraphicsScene::itemAt ?

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 3 Posters 3.0k Views 3 Watching
  • 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.
  • M Offline
    M Offline
    Mikeeeeee
    wrote on last edited by
    #1

    Hi!
    I have QGraphicsScene
    How use QGraphicsScene::itemAt ?
    What should be in place of const QTransform &deviceTransform?

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

      Hi,

      Straight from the documentation:

      deviceTransform is the transformation that applies to the view, and needs to be provided if the scene contains items that ignore transformations.
      

      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
      2
      • M Offline
        M Offline
        Mikeeeeee
        wrote on last edited by
        #3

        But how to use it? I'm drawing on a QGraphicsScene and I want this method to get the element under the mouse.

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

          Are you sure you're not rather looking for the equivalent in QGraphicsView ?

          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
          1
          • M Offline
            M Offline
            Mikeeeeee
            wrote on last edited by
            #5

            I honestly don't care. I have a separate class inherited from QGraphicsScene. In this class I draw on QGraphicsScene. And I need to get information about the drawn object under the mouse How can this be implemented?

            JKSHJ 1 Reply Last reply
            -2
            • M Mikeeeeee

              I honestly don't care. I have a separate class inherited from QGraphicsScene. In this class I draw on QGraphicsScene. And I need to get information about the drawn object under the mouse How can this be implemented?

              JKSHJ Offline
              JKSHJ Offline
              JKSH
              Moderators
              wrote on last edited by
              #6

              @Mikeeeeee said in How use QGraphicsScene::itemAt ?:

              In this class I draw on QGraphicsScene.

              ...and you display the scene using a QGraphicsView, right?

              And I need to get information about the drawn object under the mouse

              QGraphicsScene does not understand mouse coordinates. QGraphicsView transforms mouse coordinates into scene coordinates.

              You have two options to get the item under your mouse:

              • Use QGraphicsView::itemAt(), OR
              • Call QGraphicsView::mapToScene() followed by QGraphicsScene::itemAt().

              More info: https://doc.qt.io/qt-5/graphicsview.html#coordinate-mapping

              Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

              1 Reply Last reply
              2

              • Login

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