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. QPainterPath line to curve
Qt 6.11 is out! See what's new in the release blog

QPainterPath line to curve

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 4.4k 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.
  • appollosputnikA Offline
    appollosputnikA Offline
    appollosputnik
    Banned
    wrote on last edited by
    #1

    I have drawn a straight line using QPainterPath.
    [code]
    QPainter painter(this);
    QPainterPath path;
    path.moveTo(QPointF(B_Point));
    path.lineTo(QPointF(D_Point));
    painter.drawPath(m_BiscepLoopPath);
    [/code]
    BD is a straightline. Now I have to modify this line to a curve so that BD length become 100 pixel. Stright line BD length is only 50. so the line has bend startpoint B and endpoint D remains same but it should match the length to be 100.

    Please help me how can I do it.? Thanks Sujan

    1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      Hi,

      Will "quadTo":http://qt-project.org/doc/qt-5.0/qtgui/qpainterpath.html#quadTo help you? But don't know how to make the curve exactly 100 pixels.

      157

      1 Reply Last reply
      0
      • raven-worxR Offline
        raven-worxR Offline
        raven-worx
        Moderators
        wrote on last edited by
        #3

        basically it's the following:
        @
        QPointF c;
        //calculate c
        QPainter painter(this);
        QPainterPath path;
        path.moveTo(QPointF(B_Point));
        path.quadTo(c,QPointF(D_Point));
        painter.drawPath(path);
        @
        The hard part is doing the math to "calculate the arc length":http://en.wikipedia.org/wiki/Curve_length and the control point.
        See "this":http://stackoverflow.com/questions/15445260/javascript-canvas-curve-with-fixed-length for example.

        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
        If you have a question please use the forum so others can benefit from the solution in the future

        1 Reply Last reply
        0
        • appollosputnikA Offline
          appollosputnikA Offline
          appollosputnik
          Banned
          wrote on last edited by
          #4

          how can we control the length of the curve drawn.

          1 Reply Last reply
          0
          • appollosputnikA Offline
            appollosputnikA Offline
            appollosputnik
            Banned
            wrote on last edited by
            #5

            I have a length of 100 my curve should be a length of 100. how can we give this as input and find the control point.

            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