Results 1 to 4 of 4

Thread: draw a curve on qt

  1. #1
    Join Date
    Dec 2014
    Posts
    2
    Qt products
    Qt3 Qt5
    Platforms
    MacOS X

    Default draw a curve on qt

    Hi,

    I'm trying to draw an helix on a qt dialog or widget but it's not working!

    here are the parametric equations of an helix in 2d.

    x=30*cos(2*pi*t)
    y=t;

    that's what i have written so far in the paintEvent function
    but the curve does not appear;

    void MainWindow:aintEvent(QPaintEvent *){
    QPainter paint(this);
    for(qreal i=0;i<2*M_PI;i=i+0.1){
    y=+300*cos(i); // I know that i did not use the same values that i have written above, i don't care about the values as long
    QPoint T(y,i); // as i can draw a random helix!
    polygon.push_back(T);
    }
    paint.drawPolygon(polygon);

    }



    PS: i don't want to use a graph. Actually i'm trying to draw a spring i need it for a project i'm working on

    Thanks For your help

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: draw a curve on qt

    Have you checked that the values you are generating are within the visible range?

    0 <= x <= width()
    0 <= y <= height()

    Cheers,
    _

  3. #3
    Join Date
    Dec 2014
    Posts
    2
    Qt products
    Qt3 Qt5
    Platforms
    MacOS X

    Default Re: draw a curve on qt

    Thanks anda_skoa, but i have found the problem!

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,319
    Thanks
    316
    Thanked 870 Times in 857 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: draw a curve on qt

    but i have found the problem!
    The purpose of this forum is not just to ask questions, but to also give your solution when you get something working. Telling the world that "I solved it" isn't very helpful to the rest of the forum readers who don't know what you did wrong.

Similar Threads

  1. draw curve
    By szisziszilvi in forum Qt Programming
    Replies: 6
    Last Post: 25th January 2011, 08:38
  2. Replies: 1
    Last Post: 22nd January 2010, 14:34
  3. Draw dynamic curve with various colors...
    By jiapei100 in forum Qwt
    Replies: 0
    Last Post: 25th October 2009, 03:31
  4. Want to draw Curve
    By santhoshv84 in forum Qt Programming
    Replies: 1
    Last Post: 12th September 2008, 07:14
  5. Wants to draw Luminious Curve
    By santhoshv84 in forum Qt Programming
    Replies: 1
    Last Post: 22nd June 2008, 22:45

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.