January 28, 2012

alanka_kishore alanka_kisho..
Lab Rat
5 posts

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

 

  1. void MainWindow::on_addButton_clicked()
  2. {
  3.     ui->label->setText(ui->textEdit->toPlainText()  + ui->textEdit_2->toPlainText());
  4.  
  5. }

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

7 replies

January 28, 2012

alanka_kishore alanka_kisho..
Lab Rat
5 posts

okk, coool

any one plz reply for this post…
How to Adding of two values form the two textEdit contrlos?? [developer.qt.nokia.com]

January 28, 2012

Andre Andre
Mad Scientist
4034 posts

What is the problem you are experiencing exactly?

 Signature 

Nokia Certified Qt Specialist.
Interested in Qt consultancy and job opportunities.

January 28, 2012

Andre Andre
Mad Scientist
4034 posts

alanka_kishore wrote:
okk, coool

any one plz reply for this post…
How to Adding of two values form the two textEdit contrlos?? [developer.qt.nokia.com]

I have moved this post from this totally unrelated topic [developer.qt.nokia.com] 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.

 Signature 

Nokia Certified Qt Specialist.
Interested in Qt consultancy and job opportunities.

January 28, 2012

alanka_kishore alanka_kisho..
Lab Rat
5 posts

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

January 28, 2012

Andre Andre
Mad Scientist
4034 posts

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.

 Signature 

Nokia Certified Qt Specialist.
Interested in Qt consultancy and job opportunities.

January 28, 2012

alanka_kishore alanka_kisho..
Lab Rat
5 posts

thank you…
I will try today…

January 31, 2012

mkhpad mkhpad
Lab Rat
12 posts

This might be helpful if u understand it………

http://developer.qt.nokia.com/forums/viewthread/4494

 Signature 

Harish.M

 
  ‹‹ Help to write samples in Qt_SDK_Win_offline_v1_1_4_en??      Getting the Gallery Imagepath in Phone to save image in QML ››

You must log in to post a reply. Not a member yet? Register here!