I had a break in writing a code recently because I am during examination session at my university. I passed most of the exams and I had some time to write a little bit. I wrote new widget which I called PointWidget. It will replace Point class in my ThermodynamicProcesses calculator. It is a cointainer class with display and input widgets inside. It will simplyfy code a lot. First of all it will remove my UI scrambled code. It is Object-Oriented because unfortunately my UI creating code was more procedural then OO.
#include <QtWidgets> class PointWidget : public QGroupBox { Q_OBJECT public: explicit PointWidget(QWidget *parent = 0); ~PointWidget(); void initAttributes(); void setMassStream(double newMassStream); void setTemperature(double newTemperature); void setRelativeHumidity(double newRelativeHumidity); void setHumidity(double newHumidity); void setPartialPressure(double newPartialPressure); void setEnthalpy(double newEnthalpy); double getMassStream() const; double getTemperature() const; double getRelativeHumidity() const; double getHumidity() const; double getPartialPressure() const; double getEnthalpy() const; private: QFormLayout * groupBoxFormLayout; QDoubleSpinBox * massStreamSpinBox; QDoubleSpinBox * temperatureSpinBox; QDoubleSpinBox * relativeHumiditySpinBox; QDoubleSpinBox * humiditySpinBox; QDoubleSpinBox * partialPressureSpinBox; QDoubleSpinBox * enthalpySpinBox; void createLayout(); }
Simplifity can be seen in header file, old UI class was couple time bigger. It inherits from QGroupBox widget from QT library so these object will be inserted in TabWidget layouts. It isn’t finished yet ( I have to study for exams ) but I think that I will finish it this week. When I do it and implenet it I will update gitHub account.
Kind Regards.
Pass the `this` pointer to the widget constructors. This way, you won’t have to delete them manually in your destructor – as you shouldn’t (RAII and it’s alternatives were invented for a reason 😉 )