Results 1 to 5 of 5

Thread: QTextEdit Cursor

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2010
    Posts
    52
    Thanks
    6
    Thanked 2 Times in 2 Posts

    Default QTextEdit Cursor

    Hi,
    Is there anyway to ensure the cursor continues to be shown in a QTextEdit when a menu, (or right click popup menu), is shown ?

    Cheers in advance.
    Chris.

  2. #2
    Join Date
    Sep 2010
    Posts
    12
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QTextEdit Cursor

    when menu popup focus from text edit shifts to menu.
    Use
    widget->setfocus;

  3. #3
    Join Date
    Feb 2010
    Posts
    52
    Thanks
    6
    Thanked 2 Times in 2 Posts

    Default Re: QTextEdit Cursor

    Thanks, I'll give it a go.

  4. #4
    Join Date
    Feb 2010
    Posts
    52
    Thanks
    6
    Thanked 2 Times in 2 Posts

    Default Re: QTextEdit Cursor

    Simply calling setFocus on my QTextEdit after showing the popup menu didnt work, and also prevented switching focus to other controls as the QTextEdit always took it back again.

    Answering my own original question, the solution I found was to effectively filter focusOutEvents, eg,

    Qt Code:
    1. void MyTextEdit::focusOutEvent(QFocusEvent *event)
    2. {
    3. Qt::FocusReason r = event->reason();
    4. if ((r == Qt::PopupFocusReason) ||
    5. (r == Qt::MenuBarFocusReason)) {
    6. } else {
    7. QTextEdit::focusOutEvent(event);
    8. }
    9. }
    To copy to clipboard, switch view to plain text mode 

    Can anyone see any fault in doing this ?
    Also, it leaves the cursor blinking. Is there any way to turn it hard on - ie, not blinking ?

    Cheers,
    Chris.

  5. #5
    Join Date
    Oct 2019
    Posts
    2
    Qt products
    Platforms
    MacOS X

    Default Re: QTextEdit Cursor

    the cursor is still blinking, but the textedit do not receive any keyboard event

Similar Threads

  1. QTextEdit and cursor
    By newplayer in forum Qt Programming
    Replies: 1
    Last Post: 31st July 2008, 00:24
  2. Size of the cursor in QTextEdit
    By Ankitha Varsha in forum Qt Programming
    Replies: 3
    Last Post: 22nd January 2008, 13:32
  3. Setting a cursor on QTextEdit
    By Erlendhg in forum Qt Programming
    Replies: 6
    Last Post: 20th March 2007, 18:53
  4. How to synchronize text cursor and cursor in QTextEdit
    By kennyxing in forum Qt Programming
    Replies: 6
    Last Post: 18th February 2007, 10:14
  5. QTextEdit: I can not see the cursor by deafult
    By sukanyarn in forum Qt Programming
    Replies: 1
    Last Post: 10th October 2006, 08:55

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.