PDA

View Full Version : difference b/w QLineEdit() and QTextEdit()



wagmare
19th July 2009, 12:44
hi friends,

can any one please clarify my doubt .. where should i use QLineEdit at exact situation ...

where i can replace QLineEdit with QTextEdit and inverse ...
generally i am asking this question ...

nish
19th July 2009, 13:47
as the name suggesst.. use line edit when there are few words to enter without line break.(name, password, phone, etc)

tjm
19th July 2009, 13:47
My humble advice: Default to using a QLineEdit; use a QTextEdit when you allow the user to enter long free-form (possibly rich/HTML) text.

QLineEdit is better for validating user input. QLineEdit has inputMask and validator. Of course, you can validate any text you want (including QLineEdit and QTextEdit) with a regular expression.

Use QLineEdit when the user enters a password. Set the echoMode.

Use QLineEdit when you would like to suggest valid values via its completer.

QLineEdit does support rich text, but in this case use a QTextEdit instead.

In the small number of cases where both a QLineEdit and a QTextEdit can be used interchangeably, use a QLineEdit.

wagmare
19th July 2009, 14:41
Thanks to both ...
but is there any advantage of QTextEdit over QLineEdit() other than long stream strings .. just asking because now i am going to use default text enter all to QLineEdit .

nish
20th July 2009, 01:54
text edit can render html... i dont know why you are so confused.? just like radiobutton and pushbutton are two different things for two different problems... similarly textedit and lineedit are different. and if you use one in place of another it will look odd,.

wagmare
20th July 2009, 05:26
exactly ... i use QLineEdit instead of QTextEdit() to get stdOut of a linux command ethtool test ...using QProcess()

it returns only one line but actual ethtool returns six lines .. so now i am cleared thanks for the reply ...

aamer4yu
20th July 2009, 05:33
If you have simple text, go for QLineEdit, else if you have html, rich text, images, etc then you need to opt for QTextEdit. You cant embedd a table inside a QLineEdit, can u ?

wagmare
20th July 2009, 05:37
If you have simple text, go for QLineEdit, else if you have html, rich text, images, etc then you need to opt for QTextEdit. You cant embedd a table inside a QLineEdit, can u ?

thanks for reply ... yes i think even we cant add image in QLineEdit() ..