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. Math functions in Qt.
Forum Update on Monday, May 27th 2025

Math functions in Qt.

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 6.0k 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.
  • B Offline
    B Offline
    Bertie
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      [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!

      1 Reply Last reply
      0
      • B Offline
        B Offline
        Bertie
        wrote on last edited by
        #3

        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?

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andre
          wrote on last edited by
          #4

          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.

          1 Reply Last reply
          0
          • B Offline
            B Offline
            Bertie
            wrote on last edited by
            #5

            [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

            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