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. [SOLVED] QPainterPath resize graph
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] QPainterPath resize graph

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    Hello, I am drawing a graph with QPainterPath... Below is an image of what I want to achieve and have no idea how...

    !http://i.gyazo.com/80606a19aa1ec4530ddeeb3f8184995c.png(i)!

    @
    double step = 0.01
    QPainterPath groupPath;

    groupPath.moveTo(10, height() - 10);
    
    while(t <= 5){
        x = (35 * qCos(3.14/4) * t);
        y = ((35 * qSin(3.14/4) * t) - (9.81 * qPow(t, 2)) / 2);
        groupPath.lineTo(x + 10, (height() - y) - 10);
        groupPath.moveTo(x + 10, (height() - y) - 10);
    
        t += step;
    }
    
    groupPath.closeSubpath();
    

    QPainter painter(this);
    painter.setRenderHint(QPainter::Antialiasing);

    painter.drawPath(groupPath);@
    
    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      You are using fixed values to determine your points (35 and 9.81) you need to take into account the width and height of your widget.

      Hope it helps

      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
      0

      • Login

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