Results 1 to 8 of 8

Thread: Dynamic values for qSin and qCos giving error

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2016
    Posts
    4
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Smile Dynamic values for qSin and qCos giving error

    Hi,

    I was trying to draw a circle, and I need two lines inside the circle starting from the origin.
    The code I used is :

    Qt Code:
    1. QPainter Painter(this);
    2. Painter.setRenderHint(QPainter::Antialiasing,true) ;
    3.  
    4. Painter.setPen(QPen(QColor(Qt::black)));
    5. Painter.drawEllipse((circleX-(circleRadius)),(circleY-(circleRadius)),circleRadius*2,circleRadius*2); // Drawing the ellipse (giving same value for height and with)
    6.  
    7. Painter.setPen(QPen(QColor(Qt::black)));
    8. Painter.drawLine(circleX,circleY,circleX+circleRadius,circleY); // Drawing the first line, starting from origin to its right side.
    9. Painter.drawLine(circleX,circleY,circleX+(circleRadius*(qCos(angle*3.14/180.0))),circleY-(circleRadius*(qSin(angle*3.14/180.0)))); // Drawing second line. Starting from origin, the angle value with respect to first line is "angle"
    To copy to clipboard, switch view to plain text mode 
    Screenshot from 2016-05-09 19:24:40.png

    The output i need to get as shown in figure.
    But while drawing second line I'm getting a run time error...
    Alignment trap: not handling instruction ed840a00 at [<764c58cc>]
    Unhandled fault: alignment exception (0x801) at 0x3fc8f5c3
    If I gave angle value as static, its working fine.

    Eg:
    Painter.drawLine(circleX,circleY,circleX+(circleRa dius*(qCos(60*3.14/180.0))),circleY-(circleRadius*(qSin(60*3.14/180.0))));

    Can anyone tell me what I'm doing wrong and how to overcome this??
    Thanks in advance.
    Last edited by sreejithsjt; 9th May 2016 at 15:21.

Similar Threads

  1. Replies: 1
    Last Post: 26th April 2016, 14:46
  2. Replies: 3
    Last Post: 30th April 2012, 07:39
  3. Replies: 4
    Last Post: 31st January 2012, 08:59
  4. WCHAR to QString giving error in vs2005
    By ucomesdag in forum Qt Programming
    Replies: 2
    Last Post: 1st May 2008, 23:25
  5. "make" is giving an error
    By Sarma in forum Qt Programming
    Replies: 6
    Last Post: 21st August 2006, 14:28

Tags for this Thread

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.