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 pedigree chart

Creating a pedigree chart

Scheduled Pinned Locked Moved Solved General and Desktop
qgraphicsviewqgraphicssceneqgraphicsitem
7 Posts 3 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.
  • B Offline
    B Offline
    ByronCoughlin
    wrote on last edited by
    #1

    I would like to create a family pedigree chart. The tree should contain rounded rectangles with text inside the rectangle such as persons name. I would like to use a Qgraphicsscene. How can I create a single object that contains what I need so that I can addItem to scene.

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

      Hi and welcome to devnet,

      Do you mean combining a QGraphicsTextItem and a custom QGraphicsItem drawing a rounded rectangle like shown in the documentation of the class ?

      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
      3
      • B Offline
        B Offline
        ByronCoughlin
        wrote on last edited by
        #3

        I have been over each of the documents. I believe that the QGraphicsItem class document gives me a clue on how to get it done. But I not sure if I should be going towards the SimpleItem class example. Or using the part where it says items can contain other items. The tree would have a few hundred items.

        mrjjM 1 Reply Last reply
        0
        • B ByronCoughlin

          I have been over each of the documents. I believe that the QGraphicsItem class document gives me a clue on how to get it done. But I not sure if I should be going towards the SimpleItem class example. Or using the part where it says items can contain other items. The tree would have a few hundred items.

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @ByronCoughlin
          Hi
          Basically you would create a custom item to draw the nodes as you want to.
          Maybe a simply composite class would be enough, reusing the existing items
          where your class would then setup a rect and text element.
          There is also the option to simply draw it as you want.
          https://www.bogotobogo.com/Qt/Qt5_QGraphicsView_QGraphicsScene_QGraphicsItems.php

          B 1 Reply Last reply
          2
          • mrjjM mrjj

            @ByronCoughlin
            Hi
            Basically you would create a custom item to draw the nodes as you want to.
            Maybe a simply composite class would be enough, reusing the existing items
            where your class would then setup a rect and text element.
            There is also the option to simply draw it as you want.
            https://www.bogotobogo.com/Qt/Qt5_QGraphicsView_QGraphicsScene_QGraphicsItems.php

            B Offline
            B Offline
            ByronCoughlin
            wrote on last edited by
            #5

            @mrjj So it sounds like I need to create a class that derives from QGraphicsItem. Have the boundingrect = to rounded rectangle. And in the paint add my text.

            mrjjM 1 Reply Last reply
            0
            • B ByronCoughlin

              @mrjj So it sounds like I need to create a class that derives from QGraphicsItem. Have the boundingrect = to rounded rectangle. And in the paint add my text.

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @ByronCoughlin
              well i would do it that way since its pretty simple painting operations
              and you seems not to need to be able to click on the sub items.
              (like the text) so just painting seems fine as opposed to maintaining
              sub items Text/rect. Of cause it really depends on the actual use case.

              B 1 Reply Last reply
              3
              • mrjjM mrjj

                @ByronCoughlin
                well i would do it that way since its pretty simple painting operations
                and you seems not to need to be able to click on the sub items.
                (like the text) so just painting seems fine as opposed to maintaining
                sub items Text/rect. Of cause it really depends on the actual use case.

                B Offline
                B Offline
                ByronCoughlin
                wrote on last edited by
                #7

                @mrjj There are other obstacles that I need to overcome. But this way seems to be the solution that i am implementing.
                Thanks

                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