PyQt or PySide: QTextEdit deselects all
I am using PySide (PyQt is good too) and I want to undo everything inside QTextEdit. Selecting everything is very simple and it is done by self.textedit.selectAll (), but I cannot find an easy way to cancel everything. Is there an easy way to do this that I don't know or is it more difficult?
Thank.
source to share
You want to get QTextCursor
forQTextEdit
my_text_cursor = my_text_edit.textCursor()
Then clear the selection QTextCursor
my_text_cursor.clearSelection()
Then update with QLineEdit
new one QTextCursor
(see the documentation for QTextEdit.textCursor()
which indicates updating the returned QTextCursor
one.doesn't actually affect QTextEdit
unless you also call the following)
my_text_edit.setTextCursor(my_text_cursor)
source to share
The same, isn't it?
QLineEdit.deselect (self)
The text of everything in your object.
Example
. myQLineEdit = QLineEdit() . . myQLineEdit .selectAll() . . myQLineEdit.deselect() .
Link : http://pyqt.sourceforge.net/Docs/PyQt4/qlineedit.html#deselect
Or, if you want to deselect everyone QLineEdit
, just select Children QLineEdit
and deselect everything:
myQWidget= QWidget() . . listsMyQLineEdit = myQWidget.findChildren(QLineEdit) for myQLineEdit in listsMyQLineEdit: myQLineEdit.deselect() . .
Hello,
source to share