PDA

View Full Version : problem in setting cursor position in readOnly QTextEdit()



wagmare
21st March 2009, 13:51
hi friends ,
how can i set the cursor position of a readonly QTextEdit() after it get input to the top position ...
like this if the user click a button i am displaying a big paragraph but it showing only the tail position but i want to show the front text first ... i try


QTextCursor cursor(editor->textCursor());
cursor.movePosition(QTextCursor::Start);

but its not working ... i try setCursorPosition(1,1) but it says its not a member function ...
then i tried


resultTextEdit->cursorForPosition(startPos);

but i dont know how to set it ... please help ...
please help

rexi
21st March 2009, 18:25
how can i set the cursor position of a readonly QTextEdit() after it get input to the top position ...
like this if the user click a button i am displaying a big paragraph but it showing only the tail position but i want to show the front text first ... i try


QTextCursor cursor(editor->textCursor());
cursor.movePosition(QTextCursor::Start);


According to the documentation, QTextEdit::textCursor() returns a copy of the cursor, and changes to that do not affect the QTextEdit. Try to add a QTextEdit::setTextCursor() after the above code to tell the QTextEdit to use the modified cursor.

wagmare
22nd March 2009, 10:16
According to the documentation, QTextEdit::textCursor() returns a copy of the cursor, and changes to that do not affect the QTextEdit. Try to add a QTextEdit::setTextCursor() after the above code to tell the QTextEdit to use the modified cursor.

yes it worked , thanks a lot ....

nagamanohar
3rd September 2012, 07:32
this below code will work for setting the cursor position in read only mode....

QTextCursor cursor(textEdit->textCursor());
cursor.movePosition(QTextCursor::Start);
textEdit->setTextCursor(cursor);