继承QLineedit类,重写Fousinevent和Focusoutevent判断在哪个文本框编辑,可是两个文本框都有光标在闪
类中的两个事件代码是:
void SpecialLineEdit::focusInEvent(QFocusEvent *){
this->setEnabled(true);
this->setFocus();
if(this->text()==InitialText){ this->clear(); }
}
void SpecialLineEdit::focusOutEvent(QFocusEvent *){
if(this->text()==NULL){ this->setText(InitialText); }
this->clearFocus();
}