Math functions in Qt.



  • I'm not sure if I need to start a new thread, but I don't want to clog the board so I'll put it here. Could anyone tell me how I'd get mathematical functions into my code, such as Sine / Cosine etc.? Is there a math library I have to include?

    Thanks again

    Split off from "Reading from a PlainTextEdit":http://developer.qt.nokia.com/forums/viewthread/4325/ and renamed the thread; Andre



  • [quote author="Volker" date="1299624005"]You can find some information "here":http://lmgtfy.com/?q=c+math+library[/quote]

    ROTFLOL! I'll have to keep that one around!



  • Thanks for that - I was trying to use #include <qtcore/qmath.h>, however I got the error 'qSqrt was not declared in this scope' when trying to run it. Whilst your suggestion does work, could anyone clarify why qmath didn't work, as I'd like to know what I'm doing wrong?



  • Depending on your platform, the header name is case sensitive. Also, you don't show what type you try to get the square root from? The functions in that header only work on qreal.



  • [quote author="Andre" date="1299693029"]Depending on your platform, the header name is case sensitive.[/quote]

    The simplest answer is always right - I'd got qsqrt instead of qSqrt (but when I posted the error message I actually managed to type it with the right case!)

    Thanks a lot


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.