Synchronize 2 QlineEdit
Dear all, I have a window with some QlineEdit fields and I would like to synchronize 2 of them so that when I change the text in one, also the other is updated. For the moment I have solved the problem creating a slot textChanged () for each of the 2 fields and inside putting a setText () to the other field. Is there some other implementation that gives the same result but without having to modify both slots?
You can directly connect
QLineEdit::textChanged(const QString &text)
void setText(const QString &)
Then typing in one will type same in other.
Yes, this is exactly what I am doing. I just wanted to know is there is a smarter way to synchronise two or more fields.
Ok, i read it like you implemented a slot to set text and not directly used
2 connects. (with no slot implementation). that is the most compact way.
There is also
Which makes it easy to share a model with multiple widgets.