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. Qt drawing lines
Forum Updated to NodeBB v4.3 + New Features

Qt drawing lines

Scheduled Pinned Locked Moved General and Desktop
6 Posts 4 Posters 5.5k Views 1 Watching
  • 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.
  • K Offline
    K Offline
    knmaheshy2k
    wrote on last edited by
    #1

    We are building a tool using QT for some of our research. The input for our tool is a data flow model where we specify the flow of data from one actor to another. In simple words, we have different actors connected each other by lines.

    We are specifying the lines currently as a line segment, (x_start, y_start) to (x_end, y_end). So when QT draws it, it draws a line as shown in Figure 1.

    http://imageshack.us/photo/my-images/407/32971773.png/

    What we want: When we specify end points of line (x_start, y_start) to (x_end, y_end), it should draw a line as shown in Figure 2.

    http://imageshack.us/photo/my-images/402/84772692.png/

    Is there any easy way to achieve this?

    Thanks in advance.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      Not all that difficult, but there is no automated way to do it. However, it would just be a few lines of code...

      1 Reply Last reply
      0
      • K Offline
        K Offline
        knmaheshy2k
        wrote on last edited by
        #3

        Thanks Andre for responding. Could you describe the idea that you have in mind? I also want the lines not to run over some existing actor. Currently it is drawing on top of another actor.

        1 Reply Last reply
        0
        • K Offline
          K Offline
          Kxyu
          wrote on last edited by
          #4

          You should give a try to some thinking, it's not difficult but time-taking.

          Simple polyline connection can be done like this:
          @
          QPoint points[4]={
          QPoint(x_start,y_start),
          QPoint((x_start+x_end)/2,y_start),
          QPoint((x_start+x_end)/2,y_end),
          QPoint(x_end,y_end)
          };

          painter.drawPolyline(points,4);

          @

          1 Reply Last reply
          0
          • A Offline
            A Offline
            andre
            wrote on last edited by
            #5

            [quote author="knmaheshy2k" date="1319840368"]Thanks Andre for responding. Could you describe the idea that you have in mind? I also want the lines not to run over some existing actor. Currently it is drawing on top of another actor.

            [/quote]

            Hmmm... That is a complication that you did not mention before. You will have to come up with finding a suitable path yourself then. That is something Qt can not help you with.

            1 Reply Last reply
            0
            • G Offline
              G Offline
              giesbert
              wrote on last edited by
              #6

              I would start to google for some autorouting autolayouting code for that.
              Qt does not have that build in.

              Nokia Certified Qt Specialist.
              Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

              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