[Solved][Alternative]Click event using eventfilter in QlineEdit
-
hey everybody
Im havin lil trouble with the eventfilters. I have a line edit which has the a default text"Click to change password". I want to clear the text automatically when the user presses the lineedit. Since line edit does not have a click event. I have used a event filter.
In the constructor of the class, I have set the following
@
ui->passwordSetLbl->installEventFilter(this);
@and this is my eventfilter
@
bool SettingForm::eventFilter(QObject *obj, QEvent *event)
{
if(obj==ui->passwordSetLbl)
{
if(event->type() == QEvent::MouseButtonPress)
{
checkClearPassword();
return true;
}
else
return false;} else { return QDialog::eventFilter(obj,event); }
}
@It works right for the first time. Suppose i write some text in the line edit, When i click on the LineEdit, nothing happens. Im not able to edit it again.!! :(
alfah
-
I recommend you use "QLineEdit::placeholderText":http://doc.qt.nokia.com/latest/qlineedit.html#placeholderText-prop
-