Results 1 to 12 of 12

Thread: setCursorPosition.

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: setCursorPosition.

    Yes, sorry. I was talking about Qt 4.

    But how about QTextEdit::moveCursor() then?
    J-P Nurmi

  2. #2
    Join Date
    Dec 2006
    Posts
    123
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: setCursorPosition.

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

  3. #3
    Join Date
    Dec 2006
    Posts
    123
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: setCursorPosition.

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

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: setCursorPosition.

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

  5. #5
    Join Date
    Dec 2006
    Posts
    123
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: setCursorPosition.

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

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: setCursorPosition.

    QTextEdit in Qt3 was somewhat buggy, so you might be experiencing some side effect.
    Maybe instead of placing \n you should use QTextEdit::insertParagraph()?

  7. #7
    Join Date
    Dec 2006
    Posts
    123
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: setCursorPosition.

    hi...

    its working successfully...thanks a lot to you and to everyone.....

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
  •  
Qt is a trademark of The Qt Company.