Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

[SOLVED] QPainterPath resize graph



  • 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);@

  • Lifetime Qt Champion

    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


Log in to reply