Important: Please read the Qt Code of Conduct -

How to Adding of two values form the two textEdit contrlos??

  • @
    void MainWindow::on_addButton_clicked()
    ui->label->setText(ui->textEdit->toPlainText() + ui->textEdit_2->toPlainText());

    Help me please..
    i am starter in this....
    i didnt find function for the adding..
    i am using.. "Qt_SDK_Win_offline_v1_1_4_en"

    Edit: please use @ tags around code sections to improve readability; Andre

  • okk, coool

    any one plz reply for this post...
    "How to Adding of two values form the two textEdit contrlos??":

  • What is the problem you are experiencing exactly?

  • [quote author="alanka_kishore" date="1327739552"]okk, coool

    any one plz reply for this post...
    "How to Adding of two values form the two textEdit contrlos??":[/quote]

    I have moved this post from this totally unrelated "topic": to where it belongs. Please don't do this kind of thing. It is very rude to cry out for attention to your own problems in the middle of somebody else's conversation on an unrelated issue.

  • ok cool, thank you
    i want to prepare simple app.. Which is like two text boxs, one submit button, one lable..
    My intenstion is to add two integer in the text boxes when i click on the submit button.. Answer will display in the lable...
    Can u please suggest.. Whay projeect i have select... Which way i can add the two intger from the text boxes...
    Waiting for reply...
    Thank you

  • Adding integers is different from "adding" strings. The latter is really a simple way to write a concatenation of two strings.

    A textbox contains a string. It does not magically become an integer. If you want to have integers, you either use a widget that supplies those directly (like, QSpinBox), or you will have to convert the string to an integer explicitly first. QString has a whole range of to<Type> methods to choose from. However, pay attention to the bool* ok flag. You are going to need it if you are converting user-entered data!

    The integers you then have (after converting from string), can be added. Now, you end up with having an integer, that you want to set as a text on a QLabel again. Luckely, you can do the conversion the other way around as well. One way for that is using QString::number(), but you can also use the QString::arg() way.

  • thank you...
    I will try today...

  • This might be helpful if u understand it.........

Log in to reply