Results 1 to 5 of 5

Thread: Enabling buttons when lineEdit has text

Hybrid View

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

    Default Re: Enabling buttons when lineEdit has text

    if (lineEdit_name->text() != " ") {
    emit allfieldsfull();
    }
    also dont use like this condition ..

    use
    QString text = lineEdit_name->text();
    if (!text.isEmpty())
    emit allfieldsfull();
    "Behind every great fortune lies a crime" - Balzac

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Wiki edits
    5

    Default Re: Enabling buttons when lineEdit has text

    Quote Originally Posted by wagmare View Post
    QString text = lineEdit_name->text();
    if (!text.isEmpty())
    emit allfieldsfull();
    Qt Code:
    1. if (!lineEdit_name->text().isEmpty())
    2. emit allfieldsfull();
    To copy to clipboard, switch view to plain text mode 
    Is even more better because of avoiding a temporary variable. But nonetheless in that case a signal is not necessary, because you can simply call your member function.

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

    Default Re: Enabling buttons when lineEdit has text


    if (!lineEdit_name->text().isEmpty())
    yes i know this is more simpler ... but for newbie i explained clearly that we check in QString function ..

    and see i use "also" .. to tell him in future u use conditions like this in different application ..
    here using textChanged() signal is the better one ... i agree ...
    "Behind every great fortune lies a crime" - Balzac

Similar Threads

  1. Unhandled exception in qatomic
    By NewGuy in forum Qt Programming
    Replies: 14
    Last Post: 23rd July 2013, 09:49
  2. QItemDelegate and enabling buttons
    By T4ng10r in forum Qt Programming
    Replies: 0
    Last Post: 8th April 2009, 15:01
  3. Lineedit text change signal
    By zgulser in forum Qt Tools
    Replies: 2
    Last Post: 19th January 2009, 13:38
  4. Replies: 5
    Last Post: 1st February 2008, 18:10
  5. widget for text AND buttons
    By nongentesimus in forum Newbie
    Replies: 2
    Last Post: 16th June 2006, 13:43

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
  •  
Qt is a trademark of The Qt Company.