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 ?
Re: How to enabled button, when i changed lineedit`s text ?
Quote:
Originally Posted by
newermind
connect( m_ui->line_edit_1, SIGNAL( textChanged(const QString &) ), this, SLOT( BUTON_IS_ENABLED ( ) ) );
What is Is this a slot of what?
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);
}
Re: How to enabled button, when i changed lineedit`s text ?
Quote:
BUTON_IS_ENABLED ( )
this should be a private slot like
void make_button_enable();
inside make_button_enable()
set button->setEnabled(true);
Quote:
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 ()
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 ?
Re: How to enabled button, when i changed lineedit`s text ?
Quote:
Originally Posted by
newermind
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.
Re: How to enabled button, when i changed lineedit`s text ?
Quote:
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:
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
Code:
connect( m_ui
->line_edit_1,
SIGNAL( textChanged
(const QString &) ),
this,
SLOT( BUTON_IS_ENABLED
( const QString &) ) );
and chane your slot to
Code:
BUTON_IS_ENABLED
( const QString &text
){
m_ui->save_button->setEnabled(!text.isEmpty());
}
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 !