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. Connect dynamically created QGraphicsItem to parent
Forum Update on Monday, May 27th 2025

Connect dynamically created QGraphicsItem to parent

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 1.5k 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.
  • N Offline
    N Offline
    neoirto
    wrote on last edited by
    #1

    Hi all,

    I look for a way to connect QGraphicsItems to its parent by Signal/Slot. I believe I can inherit from QOject, to produce signals.

    But my QGraphicsItems are dynamically created.

    • The first problem is that I haven't found the method to create any dynamically array of QGraphicsItem derived class,
    • and how to connect to its parent please ???

    Thanks in advance ;)

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

      Hi and welcome to devnet,

      You might be interested by "QGraphicsObject":http://doc.qt.io/qt-5/QGraphicsObject.html

      1. You have to create them all and add them to your array
      2. The children should not be responsible of the connection, they should only emit signals so you can change easily what is connected to that signal.

      Hope it helps

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

        The anti-spam of the forum don't let me answer !
        [EDIT] : Ok, so tx for your answer : is it possible to create a dynamic storage type of QObject class ? With Qvector perhaps ?

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

          The post size have a limit. Did you try to paste a big chunk of code ?

          Is something like
          @QVector<QObject *> myStorage;@
          What you have in mind ?

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

            I would like to do something like
            @QVector<QObject>@
            ? But it don't seem to be possible ?

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

              No it's not, QObject is not copyable

              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
              0

              • Login

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