PDA

View Full Version : How to restore the position of the textCursor?



Dark_Tower
25th April 2006, 18:08
Hi all, I use a QTextEdit to let the user insert a text. Additionaly, I let the user change the font style of this text with a button connected to a slot where I call QFontDialog::getFont. When the user changes the font, I reflect it in the text edit by reinserting all the text in the text edit:

textEdit -> setCurrentFont(font);
textEdit -> setPlainText(textEdit -> toPlainText());
The problem is that the textCursor of the text edit doesn't maintains the old position and it appears at the begining of the text. Is it an easy way to restore the "old" position of the text cursor?

PD: I've tried it by getting the text cursor before calling to setPlainText and setting it again after but it doesn't works :(

jpn
25th April 2006, 20:41
Did I understand correctly that you intend always to change the font of the whole text edit widget?
If so, use simply:


textEdit->setFont(font)