I want to get the string value from the TextEdit(GUI Widget) . let's say for example display the text of TextEdit1 to TextEdit2 after clicking the button...how is it possible please explain!!!
I want to get the string value from the TextEdit(GUI Widget) . let's say for example display the text of TextEdit1 to TextEdit2 after clicking the button...how is it possible please explain!!!
Look at the documentation for QTextEdit; pay particular attention to those functions which take/return a QString.
Indeed, instead of feeding you, we prefer to teach you how to fish.
The Qt documentation is an excellent resource. Please read it before posting. It becomes obvious then how to perform the action you require.
If you still can't work it out then ask, after explaining what you have tried already.
I have a question to ask if u don't mind..??
what is a value returned by this
ui->lineEdit->text(); Does it return a string type or something else ...
please help me because I am reallly getting confused!!!!!!!!
why the confusion?
Please take a look at the documentation of QLineEdit::text - http://doc.qt.nokia.com/latest/qlineedit.html#text-prop
It contains information about a 'setter' and a 'getter' and tells you exactly what the types are.
jerkymotion (10th March 2011)
Read the documentation; the return type of every function is documented.
Also, you started out talking about QTextEdit; now, you're referring to QLineEdit, an entirely different class. This isn't helpful.
jerkymotion (10th March 2011)
since for a line edit I wanted to copy the string value of line edit 1 to line edit 2 after pressing the button .....here's my code to do so but i couldn't success ....please help me ....
what's the matter ...
QString str;
str=ui->lineEdit->text();
ui->lineEdit_2->text()=str;
you got the 'getter' to 'get' the text, now you need to use the 'setter' to 'set' the text. I refuse to write this part for you. I can only yet again refer you to READ the documentation:
http://doc.qt.nokia.com/latest/qlineedit.html#text-prop
carefully study the 'access functions'
One more thing: if you are struggling to understand the difference between arguments of a function and the return value of a function, then I would suggest that you spend some time on google.
Last edited by schnitzel; 10th March 2011 at 20:50. Reason: clarify
After looking at this code, I think it's not the best idea for you to start programming with Qt, because it requires some C++ knowledge. Without it, you won't be able to accomplish even such simple task ( displaying the string in text edit ).QString str;
str=ui->lineEdit->text();
ui->lineEdit_2->text()=str;
I suggest reading a good C++ book ( for example this one ) before starting with Qt.
U can get the string using the:
Qt Code:
QString str; str = ui->lineEdit->text();To copy to clipboard, switch view to plain text mode
But to set this string to another lineEdit u have to do this:
Qt Code:
ui->lineEdit2->setText(str);To copy to clipboard, switch view to plain text mode
Bookmarks