Study-Cpp-CalculationChecker.

  • First QT Graphical interface.
  • Calculation checker.
  • Multiplication, sum, subtraction.

 

Button Click Event

void MainWindow::on_ObjectName_clicked()
{
    //Action
}

setText() and setNum() Methods.

ui->ObjectName->setText("Text");
ui->ObjectName->setNum("Text");
  • setText("Text")
    • receives QString as argument and set objects text.

 

  • setNum(num)
    • receives a number and converts it to string to set objects text.

 

Label Text

ui->label->setText("Text");
  • ui is a user interface pointer.

 

  • label is the label object from the interface.
    • "label" is the previously set objectName.

 

  • setText sets the the "label" text.

 

Get Text From Input (Line Edit)

QString str = ui->input->text();
  • . . .->text()
    • Returns the text available in "Line Edit".
    • Returns text as a "QString";
  • QString str = . . .
    • QString is a "string" class from QT.
    • "QString str;" creates a QString called str.