Results 1 to 8 of 8

Thread: difference b/w QLineEdit() and QTextEdit()

  1. #1
    Join Date
    Sep 2008
    Location
    Bangalore
    Posts
    659
    Thanks
    116
    Thanked 42 Times in 41 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default difference b/w QLineEdit() and QTextEdit()

    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 ...
    "Behind every great fortune lies a crime" - Balzac

  2. #2
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: difference b/w QLineEdit() and QTextEdit()

    as the name suggesst.. use line edit when there are few words to enter without line break.(name, password, phone, etc)

  3. The following user says thank you to nish for this useful post:

    wagmare (19th July 2009)

  4. #3
    Join Date
    Jul 2009
    Posts
    13
    Thanks
    1
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: difference b/w QLineEdit() and QTextEdit()

    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.

  5. The following user says thank you to tjm for this useful post:

    wagmare (19th July 2009)

  6. #4
    Join Date
    Sep 2008
    Location
    Bangalore
    Posts
    659
    Thanks
    116
    Thanked 42 Times in 41 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: difference b/w QLineEdit() and QTextEdit()

    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 .
    "Behind every great fortune lies a crime" - Balzac

  7. #5
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: difference b/w QLineEdit() and QTextEdit()

    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,.

  8. #6
    Join Date
    Sep 2008
    Location
    Bangalore
    Posts
    659
    Thanks
    116
    Thanked 42 Times in 41 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: difference b/w QLineEdit() and QTextEdit()

    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 ...
    "Behind every great fortune lies a crime" - Balzac

  9. #7
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: difference b/w QLineEdit() and QTextEdit()

    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 ?

  10. #8
    Join Date
    Sep 2008
    Location
    Bangalore
    Posts
    659
    Thanks
    116
    Thanked 42 Times in 41 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: difference b/w QLineEdit() and QTextEdit()

    Quote Originally Posted by aamer4yu View Post
    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() ..
    "Behind every great fortune lies a crime" - Balzac

Similar Threads

  1. Replies: 2
    Last Post: 10th April 2009, 02:06
  2. Pointer Question related to QLineEdit
    By ChrisReath in forum Qt Programming
    Replies: 1
    Last Post: 23rd May 2008, 15:13
  3. QTextEdit UpperCase
    By ederbs in forum Qt Programming
    Replies: 2
    Last Post: 18th November 2006, 14:41
  4. QTextEdit control
    By vijay anandh in forum Qt Programming
    Replies: 2
    Last Post: 31st May 2006, 13:14

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.