Question: Consider the partial implementation of the class BmiViewer, which allows the user to enter height in meters and weight in kilograms and returns the calculated
Consider the partial implementation of the class BmiViewer, which allows the user to enter height in meters and weight in kilograms and returns the calculated BMI body mass index:
BmiViewer declaration partial content of bmiviewer.h
#ifndef BMIVIEWERH
#define BMIVIEWERH
#include
#include
#include
#include
#include
#include
#include
class BmiViewer : public QWidget
QOBJECT
public:
BmiViewer;
void calculateBmi; private:
QLineEdit heightEntry; QLineEdit weightEntry; QErrorMessage error;
;
#endif
BmiViewer definition partial content of bmiviewer.cpp
#include "bmiviewer.h
BmiViewer::BmiViewer
setWindowTitleBMI Calculator";
QGridLayout layout new QGridLayoutthis;
QLabel inputWeightRequest new QLabelEnter weight in kilograms ;
weightEntry new QLineEdit;
QLabel inputHeightRequest new QLabelEnter height in meters ;
heightEntry new QLineEdit;
setDecMode;for setting the LCD number mode setSegmentStyleQLCDNumber::Flat;for setting LCD style
layoutaddWidgetinputWeightRequest;
layoutaddWidgetweightEntry;
layoutaddWidgetinputHeightRequest;
layoutaddWidgetheightEntry;
setLayoutlayout;
void BmiViewer::calculateBmi
content of main.cpp
#include
#include "bmiviewer.h
int mainint argc, char argv
QApplication appargc argv; BmiViewer b;
bshow;
return app.exec;;
Complete the implementation of the class BmiViewer both header and cpp files so that
it produces the following output:
when the user enters the weight and height in the above Graphical User Interface GUI and clicks the Calculate button, it calculates the BMI as weightheightheight and displays the result in the LCD number widget.
if the user enters a nonnumber in either of the QLineEdits, it displays an error message as shown below:
Note: You only need to write down the lines of code that are required to complete the implementation. Indicate where the additional code must be added in both header and cpp files However, for the function calculateBmiyou must write down the complete implementation.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
