University of South Africa
COS 2611
Polymorphic assignments: The ability of the type 'a' to hold objects that are of it's child types. e.g. a can be assigned an object of type Stock, Bond or even Savings. 3.6 When you have two or more lists in a program and one is assigned to another, they will share the same memory space until one of the lists are modified eg. append is call
...[Show More]
Polymorphic assignments: The ability of the type 'a' to hold objects that are of it's child types. e.g. a can be assigned an object of type Stock, Bond or even Savings. 3.6 When you have two or more lists in a program and one is assigned to another, they will share the same memory space until one of the lists are modified eg. append is called. Question 4 41. QLabel *weightLabel = new QLabel("Weight (kg)"); QLabel *heightLabel = new QLabel("Height (m)"); QDoubleSpinBox *weight = new QDoubleSpinBox(); QDoubleSpinBox *height = new QDoubleSpinBox(); QPushButton *calculate = new QPushButton("Calculate"); QHBoxLayout *layout = new QHBoxLayout(); layout->addWidget(weightLabel); layout->addWidget(weight); layout->addWidget(heightLabel); layout->addWidget(height); layout->addWidget(calculate); QWidget *widget = new QWidget(); widget->setLayout(layout); setCentralWidget(widget); setWindowTitle("BMI Calculator"); 4.2 double _height = height->value(); double _weight = weight->value(); //formula given: double bmi = _weight / (_height * _height); QMessageBox::information(0, "BMI", QString("Your BMI is %1") .arg(bmi)); 4.3 Views are classes responsible for generating the user interface. Model classes hold the data/ application logic used by the application. 4.4 The logic used to calculate the BMI should be placed in a separate class and an instance of that class should be created when it needs to be used in the application code. Downloaded by: francobooysen | [email protected] Distribution of this document is illegal Stuvia.com - The Marketplace to Buy and Sell your Study Material 4.5 The primary reason is for reusability of code. The separation of functionality gives developers greater flexibility to customize the presentation of items, and provides a standard model interface to allow a wide range of data sources to be used with existing item views. 4.6 A signal is emitted when a particular event occurs. Qt's widgets have many predefined signals, but we can always subclass widgets to add our own signals to them. A slot is a function that is called in response to a particular signal. 4.7 They are both declared as functions. A slot is defined the same way you would a function. A signal is not. Question 5
[Show Less]