I'm having some trouble trying to figure out how to get two line edits to constantly be in sync including cursor position.<br>I'm sure its simple, or a matter of creating the right connections, but I can't seem to figure it out.<br>
I'm hooking two line edits textChagned signal up to the other's setText slot.<br><br>Thankfully PyQt (or Qt)'s setText is smart enough to check whether the text actually changed before emitting another signal and not getting stuck in an infinite loop.<br>
The problem seems to be that setText on a QLineEdit doesn't do a similar check before changing the cursor position.<br><br>I'd like to get two line edits synced up so that I can insert text in the beginning, middle, or end of the string but after any letter gets typed the cursor goes to the end of the string.<br>
<br>Any help is appreciated.<br><br>Thanks,<br>~Eric<br><br>#!/usr/bin/env python<br><br>from PyQt4.QtCore import *<br>from PyQt4.QtGui  import *<br><br>class MyForm(QDialog):<br>    def __init__(self, parent=None):<br>        super(MyForm, self).__init__(parent)<br>
        layout = QVBoxLayout()<br>        le1 = QLineEdit()<br>        le2 = QLineEdit()<br>        layout.addWidget(le1)<br>        layout.addWidget(le2)<br>        self.setLayout(layout)<br>        <br>        self.connect(le1, SIGNAL("textChanged(QString)"), le2.setText)<br>
        self.connect(le2, SIGNAL("textChanged(QString)"), le1.setText)<br><br>if __name__ == '__main__':<br>    import sys<br>    app = QApplication(sys.argv)<br>    mf = MyForm()<br>    mf.show()<br>    sys.exit(app.exec_())<br>
<br>