1) Use QObject::sender() to identify the line edit being edited:
connect( lineEditA, SIGNAL( textEdited() ), this, SLOT(colorbackground() ) );
connect( lineEditB, SIGNAL( textEdited() ), this, SLOT(colorbackground() ) );
ProgramMain::colorbackground() {
QLineEdit* lineEdit
= qobject_cast<QLineEdit
*>
(sender
());
if (lineEdit)
lineEdit->setStyleSheet(...);
}
connect( lineEditA, SIGNAL( textEdited() ), this, SLOT(colorbackground() ) );
connect( lineEditB, SIGNAL( textEdited() ), this, SLOT(colorbackground() ) );
ProgramMain::colorbackground() {
QLineEdit* lineEdit = qobject_cast<QLineEdit*>(sender());
if (lineEdit)
lineEdit->setStyleSheet(...);
}
To copy to clipboard, switch view to plain text mode
2) Use QSignalMapper
Bookmarks