In case each lineedit has its own "Edit" button, you can wrap the line edit and push button into one class and pass through the clicked() signal of QPushButton:
Q_OBJECT
public:
{
// initialize button and line edit, prepare layout etc...
connect(_button, SIGNAL(clicked()), this, SIGNAL(buttonClicked()));
}
return _lineEdit;
}
signals:
void buttonClicked();
private:
};
//...
void Class::onClickedSignal(){
Wrapper * wrap = qobject_cast<Wrapper*>(sender());
if (wrap){
//...
}
}
class Wrapper : public QWidget{
Q_OBJECT
public:
Wrapper(QWidget * parent = NULL) : QWidget(parent)
{
// initialize button and line edit, prepare layout etc...
connect(_button, SIGNAL(clicked()), this, SIGNAL(buttonClicked()));
}
QLineEdit * lineEdit() const{
return _lineEdit;
}
signals:
void buttonClicked();
private:
QLineEdit * _lineEdit;
QPushButton * _button;
};
//...
void Class::onClickedSignal(){
Wrapper * wrap = qobject_cast<Wrapper*>(sender());
if (wrap){
QLineEdit * lineEdit = wrap->lineEdit();
//...
}
}
To copy to clipboard, switch view to plain text mode
Another way is to connect to QLineEdit::editingFinished() signal instead.
Bookmarks