Results 1 to 4 of 4

Thread: QTextEdit,QTextDocument,QTextCursor

  1. #1
    Join Date
    Aug 2006
    Posts
    77
    Thanks
    14
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default QTextEdit,QTextDocument,QTextCursor

    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.

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QTextEdit,QTextDocument,QTextCursor

    - 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.

  3. #3
    Join Date
    Aug 2006
    Posts
    77
    Thanks
    14
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QTextEdit,QTextDocument,QTextCursor

    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.

  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QTextEdit,QTextDocument,QTextCursor

    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.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.