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)

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.
  • A Offline
    A Offline
    AlvaroS
    wrote on 13 May 2016, 08:41 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
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 13 May 2016, 09:02 last edited by
      #2

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

      A 1 Reply Last reply 13 May 2016, 09:47
      1
      • M mrjj
        13 May 2016, 09:02

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

        A Offline
        A Offline
        AlvaroS
        wrote on 13 May 2016, 09:47 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!

        M 1 Reply Last reply 13 May 2016, 09:56
        0
        • A AlvaroS
          13 May 2016, 09:47

          @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!

          M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 13 May 2016, 09:56 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 ? :)

          A 1 Reply Last reply 13 May 2016, 10:00
          0
          • M mrjj
            13 May 2016, 09:56

            @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 ? :)

            A Offline
            A Offline
            AlvaroS
            wrote on 13 May 2016, 10:00 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.

            M 1 Reply Last reply 13 May 2016, 10:03
            0
            • A AlvaroS
              13 May 2016, 10:00

              @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.

              M Offline
              M Offline
              mrjj
              Lifetime Qt Champion
              wrote on 13 May 2016, 10:03 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

              4/6

              13 May 2016, 09:56

              • Login

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