PDA

View Full Version : QTextEdit,QTextDocument,QTextCursor



kemp
13th October 2006, 07:15
Hi!

I use QTextEdit in which i load a QTextDocument (Qt 4.1.4). Now I want that my document
is behawing like this:

- when i hit enter that the new location of the cursor is not the beginning of the line
but the begining of the paragraph in which i hit enter

- that i could click anywhere in the QTextEdit and the cursor will appear exactly there
and not related to the text.

Is there a quick way, any properties setting or anything like that to do this?

Thank you for your help.

high_flyer
13th October 2006, 09:16
- when i hit enter that the new location of the cursor is not the beginning of the line
but the begining of the paragraph in which i hit enter
I am not sure what you mean - you mean if you hit enter on the last line of a paragraph, you want the cursor to go to the beginning of the paragraph?

- that i could click anywhere in the QTextEdit and the cursor will appear exactly there
and not related to the text.
There are two things hear:
If all you want is to show a marking of the pixel where you clicked, while the text edit cursor works normally,its one thing.
If you mean you want a text edit cursor that can be placed anywhere in the document, between lines and between letters, then I'd say you need to reimplement the way text is drawn and managed, and I don't think this is trivial or fast to do...
But I never tried anything like this, so I might be wrong.

kemp
13th October 2006, 09:42
I am not sure what you mean - you mean if you hit enter on the last line of a paragraph, you want the cursor to go to the beginning of the paragraph?


Yes I mean that.

high_flyer
13th October 2006, 12:03
you can catch the keyevent, if its from an enter (make sure you don't mix enter and return) reposition the cursor to begining of current paragraph.