- 1. Project structure
- 2. Widget.ui
- 3. Widget.h
- 4. Widget.cpp
- 5. Conclusion
I suggest to write an application that has two input fields for variable names, two input fields with input for the values of these variables in double format, in case of entering a value other than double data type, we will set the value to Undefined .
And the last input field will be called Result (this will be TextEdit ), which will be responsible for the output of the new calculated values of the variables we entered.
The application will look like the image below.
We write a project with a minimal structure. In essence, the project has a structure that is created by default.
The only important difference from the default pro file will be that we need to connect the script module.
This is done in the JSCalculation.pro file.
QT += core gui widgets script
In this article I will not describe how I created the application form in Qt Designer, this is not so important to us, and it does not apply to the topic of the article. Just list the objects that will be used in the source code of the widget with the name of their class
- nameLineEdit_1 - QLineEdit
- nameLineEdit_2 - QLineEdit
- valueLineEdit_1 - QLineEdit
- valueLineEdit_2 - QLinEdit
- execPushButton - QPushButton
- resultTextEdit - QPlainTextEdit
Now let's proceed directly to the implementation of our project.
And now the application code itself