Simple Math Calculation Questions in QT (PyQt, Qt4 C++)



  • Im using PyQt and/or Qt4 C++ for the first time and trying create simple math calculations. What I need to do is use data from 2 inputs (QLineEdit) and run this calculation in the background:
    a - b = c
    c * 2 = d / 0.9 = sum
    The sum would then need to be printed on another QLineEdit. Is this possible in either PyQT or C++? An answer in either language would be much appreciated as I am using both.
    Also, just so all of my questions are out there, I have a number in QLineEdit and I need to find a data output based on a number range. Example:
    Input Number = 0.80
    0 - 0.19 = 5 0.2 - 0.49 = 10 0.50 - 0.79 = 15 0.80 - 1.09 = 20
    So the output (20 in this case) would need to also be output in another QLineEdit.
    Basically, the outputs are in QLineEdit because sometimes we need to change the value based on certain variables (weather, previous fertilizer applications, etc.) I am just a hobby programmer and I mainly work as a soil consultant so I am trying to build a program that inputs my lab data and I can run my calculations and speed up my turn around time. My company already runs calculations based in Excel and VB but I thought that it would be a fun project for me to try and build a new program in Qt. I have been spending countless hours in documentation, books, and tutorials and there are no answers anywhere. If there is any help that you can give me or at least give a link to something that may help, it would be greatly appreciated. Thank you very much and happy coding!


  • Moderators

    Hi @baxtorburgandy ,

    Welcome to the Qt forums

    There are some calculator examples that do what you need. You can look into them from Qt creator > examples. Search for calculator.

    Do you know about signal-slots? You will need them for sure. If input a changes send a signal, if input b changes send a signal and connect a slot that does the math.


Log in to reply
 

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