How to take keyboard input from Right to Left in a QLineEdit in Pyside?
-
0 down vote favorite
I saw something that has the following code
.QKeyEvent e(QEvent::KeyPress, Qt::Key_Direction_R, 0);
QApplication::sendEvent(this, &e);
I believe this is C++ code and I only vaguely understand what it is actually doing, some things in the Qt library I can do but a great deal of it leaves me scratching my head the I cannot 'translate' it properly, secondary question, could it be that I don't know how to read the Qt library properly ?
-
-
The same solution but without using classes, using python lambda function.
This, to writing hello presents " |olleh" and the cursor is moves to left.
@
lineEdit = QtGui.QLineEdit()
lineEdit.setAlignment(QtCore.Qt.AlignRight)
lineEdit.textChanged.connect(
lambda: lineEdit.cursorBackward(False))
@HTH