Results 1 to 9 of 9

Thread: How to enabled button, when i changed lineedit`s text ?

  1. #1
    Join Date
    Apr 2009
    Location
    İstanbul, Türkiye
    Posts
    26
    Thanks
    1

    Default How to enabled button, when i changed lineedit`s text ?

    First, My save button is disabled. And I have 10 qlineedits.

    I try to enabled button, when i changed a lineedit`s text.

    I did this;

    connect( m_ui->line_edit_1, SIGNAL( textChanged(const QString &) ), this, SLOT( BUTON_IS_ENABLED ( ) ) );

    Do I write this code, all lineedits connect ?

    Can i do this, if change something in dialog, button is enabled ?

  2. #2
    Join Date
    Dec 2007
    Posts
    628
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to enabled button, when i changed lineedit`s text ?

    Quote Originally Posted by newermind View Post
    connect( m_ui->line_edit_1, SIGNAL( textChanged(const QString &) ), this, SLOT( BUTON_IS_ENABLED ( ) ) );
    What is
    BUTON_IS_ENABLED
    Is this a slot of what?

  3. #3
    Join Date
    Apr 2009
    Location
    İstanbul, Türkiye
    Posts
    26
    Thanks
    1

    Default Re: How to enabled button, when i changed lineedit`s text ?

    BUTON_IS_ENABLED is my function.


    BUTON_IS_ENABLED ( )
    {
    m_ui->save_button->setEnabled(true);
    }

  4. #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: How to enabled button, when i changed lineedit`s text ?

    BUTON_IS_ENABLED ( )
    this should be a private slot like
    void make_button_enable();

    inside make_button_enable()
    set button->setEnabled(true);

    Do I write this code, all lineedits connect ?
    yes u have to ... to truncate lines u can use QList<QLineEdit *> but it is very tedious for simple connect ()
    "Behind every great fortune lies a crime" - Balzac

  5. #5
    Join Date
    Apr 2009
    Location
    İstanbul, Türkiye
    Posts
    26
    Thanks
    1

    Default Re: How to enabled button, when i changed lineedit`s text ?

    In this dialog change anything, these are lineedits, textedits or combo box.

    For i make button enabled, Do i have to control all widgets ?

  6. #6
    Join Date
    Dec 2007
    Posts
    628
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to enabled button, when i changed lineedit`s text ?

    Quote Originally Posted by newermind View Post
    In this dialog change anything, these are lineedits, textedits or combo box.
    For i make button enabled, Do i have to control all widgets ?
    It seems like, you want to enable buttons, for any keyboard event. So instead of controlling all widgets, use event filter. Look for QKeyEvent. In this event, enable all your buttons.

  7. #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: How to enabled button, when i changed lineedit`s text ?

    Do I write this code, all lineedits connect ?
    Yes.. connect( m_ui->line_edit_1, SIGNAL( textChanged(const QString &) ), this, SLOT( BUTON_IS_ENABLED ( ) ) ); is connectting only line_edit_1 to the slot..
    U will need to connect all line edits to ur slot..

    also make sure ur function is declared as a SLOT - private/public slots:

  8. #8
    Join Date
    Aug 2009
    Location
    Ukraine, Krivoy Rog
    Posts
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: How to enabled button, when i changed lineedit`s text ?

    Try this:
    Change your slot from BUTON_IS_ENABLED ( ) to BUTON_IS_ENABLED ( const QString &text).
    Then use
    Qt Code:
    1. connect( m_ui->line_edit_1, SIGNAL( textChanged(const QString &) ), this, SLOT( BUTON_IS_ENABLED ( const QString &) ) );
    To copy to clipboard, switch view to plain text mode 
    and chane your slot to
    Qt Code:
    1. BUTON_IS_ENABLED ( const QString &text )
    2. {
    3. m_ui->save_button->setEnabled(!text.isEmpty());
    4. }
    To copy to clipboard, switch view to plain text mode 

  9. #9
    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: How to enabled button, when i changed lineedit`s text ?

    That wont matter since you can have slot with less number of arguments than the signal !

Similar Threads

  1. Unhandled exception in qatomic
    By NewGuy in forum Qt Programming
    Replies: 14
    Last Post: 23rd July 2013, 10:49
  2. Replies: 3
    Last Post: 8th December 2011, 20:21
  3. How to change text color of push button?
    By augusbas in forum Qt Programming
    Replies: 2
    Last Post: 3rd July 2009, 11:32
  4. Custom QStyle: change only tool button text color
    By Lykurg in forum Qt Programming
    Replies: 0
    Last Post: 27th February 2009, 20:55
  5. Replies: 4
    Last Post: 29th February 2008, 11:04

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.