#include class LineEdit : public QLineEdit { public: using QLineEdit::QLineEdit; QGraphicsDropShadowEffect* dse = nullptr; void focusInEvent(QFocusEvent* event) { dse = new QGraphicsDropShadowEffect(); dse->setBlurRadius(60); dse->setOffset(0); dse->setColor(0x007eff); setGraphicsEffect(dse); QLineEdit::focusInEvent(event); } void focusOutEvent(QFocusEvent* event) { dse->deleteLater(); QLineEdit::focusOutEvent(event); } }; int main(int argc, char **argv) { QApplication app(argc, argv); QWidget w; QHBoxLayout hLay(&w); hLay.setSpacing(10); QLineEdit le1; LineEdit le2; hLay.addWidget(&le1); hLay.addWidget(&le2); w.show(); return app.exec(); }