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. QGraphicsItemGroup tooltip shown in the wrong place
Forum Updated to NodeBB v4.3 + New Features

QGraphicsItemGroup tooltip shown in the wrong place

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 462 Views 1 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.
  • ralienppR Offline
    ralienppR Offline
    ralienpp
    wrote on last edited by
    #1

    I use PySide2 v5.14.1 on Debian. There's a class that inherits from QGraphicsItemGroup to create and manage multiple QGraphicsEllipseItem as if they're one logical entity. I set a tooltip for the group and it works as expected.

    However, if I move my group to some other place on the QGraphicsScene, hovering the mouse over the object does not produce a tooltip. At the same time, I noticed that if I move the mouse to the old location of my object - the tooltip is shown, as if my object is still there at the old coordinates.

    1. How can one ensure that the tooltip moves along with the object?
    2. Is it possible in principle?

    Any suggestions on how to troubleshoot this would be greatly appreciated.

    Pl45m4P 1 Reply Last reply
    0
    • ralienppR ralienpp

      I use PySide2 v5.14.1 on Debian. There's a class that inherits from QGraphicsItemGroup to create and manage multiple QGraphicsEllipseItem as if they're one logical entity. I set a tooltip for the group and it works as expected.

      However, if I move my group to some other place on the QGraphicsScene, hovering the mouse over the object does not produce a tooltip. At the same time, I noticed that if I move the mouse to the old location of my object - the tooltip is shown, as if my object is still there at the old coordinates.

      1. How can one ensure that the tooltip moves along with the object?
      2. Is it possible in principle?

      Any suggestions on how to troubleshoot this would be greatly appreciated.

      Pl45m4P Offline
      Pl45m4P Offline
      Pl45m4
      wrote on last edited by
      #2

      @ralienpp

      Show your subclass.
      I bet, you forgot to pass the new position to its base class, so that from scene's point of view, the item is still at its old position, which triggers the tooltip there.


      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

      1 Reply Last reply
      1
      • ralienppR Offline
        ralienppR Offline
        ralienpp
        wrote on last edited by
        #3

        Thank you for your reply - you are right, the position of the group was indeed not updated.

        For the benefit of future archaeologists digging in this area, here are some additional clues:

        • the update method of my subclass was changing the position of the group's individual elements,
        • but not the position of the group itself
        • thus, everything was visually in the correct location
        • but logically the group was still in its old place

        Therefore, one needs to ensure that the update method calls self.setPos(...) somewhere.

        Pl45m4P 1 Reply Last reply
        2
        • ralienppR ralienpp

          Thank you for your reply - you are right, the position of the group was indeed not updated.

          For the benefit of future archaeologists digging in this area, here are some additional clues:

          • the update method of my subclass was changing the position of the group's individual elements,
          • but not the position of the group itself
          • thus, everything was visually in the correct location
          • but logically the group was still in its old place

          Therefore, one needs to ensure that the update method calls self.setPos(...) somewhere.

          Pl45m4P Offline
          Pl45m4P Offline
          Pl45m4
          wrote on last edited by Pl45m4
          #4

          @ralienpp said in QGraphicsItemGroup tooltip shown in the wrong place:

          thus, everything was visually in the correct location
          but logically the group was still in its old place

          Yes, exactly :)

          one needs to ensure that the update method calls self.setPos(...) somewhere

          This should happen automatically, if your subclass is correct (every change passed to base class). Usually there's no need to call update() to make position changes.
          If you move your custom item by e.g. mouse dragging the moveEvent is propagated to the base class QGraphicsItem or -Group which holds the position. Your position change was probably made only in your subclass, which paints your item at that position, but won't move it.


          If debugging is the process of removing software bugs, then programming must be the process of putting them in.

          ~E. W. Dijkstra

          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