Okay, I have been working for a few hours and here is what I have so far. It is a bit different from what you had. For background, I created buttons in the mainwindow.ui and they are labeled as follows: lineEditA, lineEditB, and lineEditSum. The button I used was a tool button and I named it calculateButton. Instead of doing all of that original formula, I am just trying to do a simple a - b = sum now just so I can get the hang of that and then work up from there. I am getting some errors while running this code. I will explain the errors after I show the code.

mainwindow.h

Qt Code:
  1. #ifndef MAINWINDOW_H
  2. #define MAINWINDOW_H
  3.  
  4. #include <QMainWindow>
  5.  
  6. namespace Ui {
  7. class MainWindow;
  8. }
  9.  
  10. class MainWindow : public QMainWindow
  11. {
  12. Q_OBJECT
  13.  
  14. public:
  15. explicit MainWindow(QWidget *parent = 0);
  16. ~MainWindow();
  17.  
  18. private slots:
  19.  
  20.  
  21. private:
  22. Ui::MainWindow *ui;
  23. void onCalculateClicked();
  24. void calculateAndDisplaySum();
  25. };
  26.  
  27. #endif // MAINWINDOW_H
To copy to clipboard, switch view to plain text mode 
main.cpp
Qt Code:
  1. #include "mainwindow.h"
  2. #include <QApplication>
  3.  
  4. int main(int argc, char *argv[])
  5. {
  6. QApplication a(argc, argv);
  7. MainWindow w;
  8. w.show();
  9.  
  10. return a.exec();
  11. }
To copy to clipboard, switch view to plain text mode 
mainwindow.cpp
Qt Code:
  1. #include <QLineEdit>
  2. #include <QToolButton>
  3. #include "mainwindow.h"
  4. #include "ui_mainwindow.h"
  5.  
  6. MainWindow::MainWindow(QWidget *parent) :
  7. QMainWindow(parent),
  8. ui(new Ui::MainWindow)
  9. {
  10. ui->setupUi(this);
  11. connect(ui->calculateButton, SIGNAL(clicked()), this, SLOT(onCalculateClicked()));
  12.  
  13. //onCalculateClicked(); -- Are these necessary?
  14. //calculateAndDisplaySum();
  15. }
  16.  
  17. MainWindow::~MainWindow()
  18. {
  19. delete ui;
  20. }
  21.  
  22. void MainWindow::onCalculateClicked()
  23. {
  24. calculateAndDisplaySum();
  25. }
  26.  
  27. void MainWindow::calculateAndDisplaySum()
  28. {
  29. double a = lineEditA->text().toDouble();
  30. double b = lineEditB->text().toDouble();
  31. double sum = a - b;
  32.  
  33. lineEditSum->setText(QString::number(sum, 'g', 2));
  34. }
To copy to clipboard, switch view to plain text mode 
mainwindow.ui
Qt Code:
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <ui version="4.0">
  3. <class>MainWindow</class>
  4. <widget class="QMainWindow" name="MainWindow">
  5. <property name="geometry">
  6. <rect>
  7. <x>0</x>
  8. <y>0</y>
  9. <width>400</width>
  10. <height>300</height>
  11. </rect>
  12. </property>
  13. <property name="windowTitle">
  14. <string>MainWindow</string>
  15. </property>
  16. <widget class="QWidget" name="centralWidget">
  17. <widget class="QLineEdit" name="lineEditSum">
  18. <property name="geometry">
  19. <rect>
  20. <x>120</x>
  21. <y>10</y>
  22. <width>31</width>
  23. <height>20</height>
  24. </rect>
  25. </property>
  26. </widget>
  27. <widget class="QLineEdit" name="lineEditA">
  28. <property name="geometry">
  29. <rect>
  30. <x>10</x>
  31. <y>10</y>
  32. <width>31</width>
  33. <height>20</height>
  34. </rect>
  35. </property>
  36. </widget>
  37. <widget class="QLineEdit" name="lineEditB">
  38. <property name="geometry">
  39. <rect>
  40. <x>60</x>
  41. <y>10</y>
  42. <width>31</width>
  43. <height>20</height>
  44. </rect>
  45. </property>
  46. </widget>
  47. <widget class="QLabel" name="label">
  48. <property name="geometry">
  49. <rect>
  50. <x>50</x>
  51. <y>10</y>
  52. <width>16</width>
  53. <height>16</height>
  54. </rect>
  55. </property>
  56. <property name="text">
  57. <string>-</string>
  58. </property>
  59. </widget>
  60. <widget class="QLabel" name="label_2">
  61. <property name="geometry">
  62. <rect>
  63. <x>100</x>
  64. <y>10</y>
  65. <width>16</width>
  66. <height>16</height>
  67. </rect>
  68. </property>
  69. <property name="text">
  70. <string>=</string>
  71. </property>
  72. </widget>
  73. <widget class="QToolButton" name="calculateButton">
  74. <property name="geometry">
  75. <rect>
  76. <x>40</x>
  77. <y>40</y>
  78. <width>71</width>
  79. <height>19</height>
  80. </rect>
  81. </property>
  82. <property name="text">
  83. <string> Calculate</string>
  84. </property>
  85. </widget>
  86. </widget>
  87. <widget class="QMenuBar" name="menuBar">
  88. <property name="geometry">
  89. <rect>
  90. <x>0</x>
  91. <y>0</y>
  92. <width>400</width>
  93. <height>21</height>
  94. </rect>
  95. </property>
  96. </widget>
  97. <widget class="QToolBar" name="mainToolBar">
  98. <attribute name="toolBarArea">
  99. <enum>TopToolBarArea</enum>
  100. </attribute>
  101. <attribute name="toolBarBreak">
  102. <bool>false</bool>
  103. </attribute>
  104. </widget>
  105. <widget class="QStatusBar" name="statusBar"/>
  106. </widget>
  107. <layoutdefault spacing="6" margin="11"/>
  108. <resources/>
  109. <connections/>
  110. </ui>
To copy to clipboard, switch view to plain text mode 
Okay, so now that's out of the way, just in case you want to compile it in QtCreator5.5 yourself, the error messages only show up on the mainwindow.cpp and they are as follows:

mainwindow.cpp:28: error: C2065: 'lineEditA' : undeclared identifier
mainwindow.cpp:28: error: C2227: left of '->text' must point to class/struct/union/generic type
type is 'unknown-type'
mainwindow.cpp:28: error: C2228: left of '.toDouble' must have class/struct/union

mainwindow.cpp:29: error: C2065: 'lineEditB' : undeclared identifier
mainwindow.cpp:29: error: C2227: left of '->text' must point to class/struct/union/generic type
type is 'unknown-type'
mainwindow.cpp:29: error: C2228: left of '.toDouble' must have class/struct/union

mainwindow.cpp:32: error: C2065: 'lineEditSum' : undeclared identifier
mainwindow.cpp:32: error: C2227: left of '->setText' must point to class/struct/union/generic type
type is 'unknown-type'

That should be it. Sorry for all the information and bombardment of code. Thank you for all the help!