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. Creating a QGraphicsTextItem that "follows" a QGraphicsItem

Creating a QGraphicsTextItem that "follows" a QGraphicsItem

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 2 Posters 109 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.
  • F Offline
    F Offline
    frnklu20
    wrote on last edited by frnklu20
    #1

    I don't know if there is already a function for this, but what i want to do is:

    when i click on the diagramscene i want it to add 2 items, one QGraphicsSvgItem and one QGraphicsTextItem, but here is the deal, when i drag and drop my QGraphicsSvgItem i want the QGraphicsTextItem to keep it up with position, kind of following him, in a same position towards the QGraphicsSvgItem.

    How can I do this?

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      See https://doc-snapshots.qt.io/qt5-dev/qgraphicsitem.html#details :

      "Items can contain other items, and also be contained by other items. All items can have a parent item and a list of children. Unless the item has no parent, its position is in parent coordinates (i.e., the parent's local coordinates). Parent items propagate both their position and their transformation to all children."
      So make one the parent of the other.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      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