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. Draw a line in Scene (not adding)
QtWS25 Last Chance

Draw a line in Scene (not adding)

Scheduled Pinned Locked Moved Unsolved General and Desktop
scenedrawqpainter
6 Posts 2 Posters 3.2k 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.
  • AlvaroSA Offline
    AlvaroSA Offline
    AlvaroS
    wrote on last edited by
    #1

    Hi everyone.
    First of all thanks a lot for helping me and reading this post.

    I woudl like to draw a line in a Scene or Qgraphicsview.
    i got that adding the line to the Scene but I do not want to adding I would like to draw the line using "void QPainter::drawLine(const QLineF & line)" with the same coordinates than in the scene.

    Is it possible to do that??

    thanks a lot!!!

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

      Hi
      well you can draw the line with mouse
      http://www.walletfox.com/course/qgraphicsitemruntimedrawing.php

      AlvaroSA 1 Reply Last reply
      1
      • mrjjM mrjj

        Hi
        well you can draw the line with mouse
        http://www.walletfox.com/course/qgraphicsitemruntimedrawing.php

        AlvaroSA Offline
        AlvaroSA Offline
        AlvaroS
        wrote on last edited by
        #3

        @mrjj I have lines coordinates in a QMap so I would like to use paintEvent to draw the lines from QMap without adding to scene.

        Is it possible.

        Thanks for replying!

        mrjjM 1 Reply Last reply
        0
        • AlvaroSA AlvaroS

          @mrjj I have lines coordinates in a QMap so I would like to use paintEvent to draw the lines from QMap without adding to scene.

          Is it possible.

          Thanks for replying!

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

          @AlvaroS said:

          QMap so I would like to use paintEvent to draw the lines from QMap without adding to scene.

          No, you cannot draw something to scene that is not inserted. at least in any good way.

          You can however, make your own item, insert that into scene,
          override paintEvent and draw lines there, but that will be inside the area of the Item, not whole scene.

          U can then make the custom item very big, but it will be come silly.

          So why do u want to have lines, but not really want to have lines ?
          something is strange here ? :)

          AlvaroSA 1 Reply Last reply
          0
          • mrjjM mrjj

            @AlvaroS said:

            QMap so I would like to use paintEvent to draw the lines from QMap without adding to scene.

            No, you cannot draw something to scene that is not inserted. at least in any good way.

            You can however, make your own item, insert that into scene,
            override paintEvent and draw lines there, but that will be inside the area of the Item, not whole scene.

            U can then make the custom item very big, but it will be come silly.

            So why do u want to have lines, but not really want to have lines ?
            something is strange here ? :)

            AlvaroSA Offline
            AlvaroSA Offline
            AlvaroS
            wrote on last edited by
            #5

            @mrjj I have lines and I have head arrows. For each line there is a head arrow. When user remove a line the head arrow is still there so i would like to remove head arrow as well when user remove a line. This happens because I add the head arrows in the scene so i thought that a good idea to solve this is not adding head arrow to the scene, just draw it.

            mrjjM 1 Reply Last reply
            0
            • AlvaroSA AlvaroS

              @mrjj I have lines and I have head arrows. For each line there is a head arrow. When user remove a line the head arrow is still there so i would like to remove head arrow as well when user remove a line. This happens because I add the head arrows in the scene so i thought that a good idea to solve this is not adding head arrow to the scene, just draw it.

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

              @AlvaroS
              ok. seems a bit messy.
              Do you really need a QGraphicsScene then ?
              You could also draw it as a custom control. you need zooming etc ?

              In any case, did u see this example
              http://doc.qt.io/qt-5/qtwidgets-graphicsview-diagramscene-example.html

              it even has arrowhead class :)

              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