hi...
can anyone say me how to move cursor position to next line using setCursorPosition...?
in the textEdit, i tried entering text->setCursorPosition(1,0);(my current cursor postion is paragraph 0).
but its not working...
hi...
can anyone say me how to move cursor position to next line using setCursorPosition...?
in the textEdit, i tried entering text->setCursorPosition(1,0);(my current cursor postion is paragraph 0).
but its not working...
Do you have more than one paragraph in your textEdit?
no... i have only a few lines in the paragraph.but its like this. i have a textedit's size as text->setGeometry(30,10,200,40 );
its a small rectangle box.i dont want the scroll bars to appear.instead i'l click a pushbutton which should move the cursor to next line...(this is similar to functioning of the enter key in our keyboard...)
Take a look at QTextCursor::movePosition(). Here's an example of usage:
Qt Code:
textEdit->setTextCursor(cursor);To copy to clipboard, switch view to plain text mode
J-P Nurmi
hi...
thanks for the reply.but i'm using qt-3.3.5. i think the class you said is in qt-4.2......
Yes, sorry. I was talking about Qt 4.
But how about QTextEdit::moveCursor() then?![]()
J-P Nurmi
hi...
yeah i found that. it works but not has that of our enter key....Also it works as our up down,back,forward arrows.i need to go the start of next line when i press the button...is it possible with the option setCursorPosition wherein we can place the cursor to the start of next line....?
i mean start of a new line. i used both QTextEdit::MoveDown and QTextEdit::MoveLineStart. the cursor only moves to existing line's start not to a new line...
"Enter" does something else than just go to the start of next line. It inserts a "\n" character in the text and this is what causes it to go to the beggining of the line, there is no "going down one line" - that's only a side effect.
If you want to mimic only the move itself, just use QTextEdit::MoveLineStart as the action for moveCursor() but if you don't have a line below, the cursor won't move because it doesn't have a place to move to - you have to add that new line there first.
hi....
yeah exactly . i tried that only.i inserted "\n" when i press the button. when i enter characters, they are displayed in the next line,but the cursor still blinks in the above line only....thats where i got stuck. i'm trying to bring cursor also down... here is my code:
void keyclass::enter()
{
str.append("\n");
text->moveCursor(QTextEdit::MoveDown,0);
text->moveCursor(QTextEdit::MoveLineStart,0);
}
str is a string . when i enter the keys in the keyboard(which i created, not the physicall connected keyboard), i'l store them in this string and display them in the textedit. so when i press enter i'l insert "\n" in the string . this causes the characters to go to the nextline while the cursor blinks in the previous. is this what u suggested...? or Am i missing something else...?
QTextEdit in Qt3 was somewhat buggy, so you might be experiencing some side effect.
Maybe instead of placing \n you should use QTextEdit::insertParagraph()?
hi...
its working successfully...thanks a lot to you and to everyone.....
Bookmarks