Results 1 to 6 of 6

Thread: QPlainTextEdit shortcut

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2010
    Location
    Zamość, Poland
    Posts
    13
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Symbian S60
    Thanks
    6

    Default Re: QPlainTextEdit shortcut

    I called QPlainTextEdit:keyPressEvent, and now all is done

    Code:
    Qt Code:
    1. void EPlainTextEdit::keyPressEvent(QKeyEvent *e)
    2. {
    3. if(e->key() == 0x01000004 or e->key() == 0x01000005)
    4. {
    5. eustia->confirm();
    6. return;
    7. }
    8. QPlainTextEdit::keyPressEvent(e);
    9. }
    To copy to clipboard, switch view to plain text mode 
    Thanks for the help.

  2. #2
    Join Date
    May 2014
    Posts
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QPlainTextEdit shortcut

    Thanks for the post - solved my problem. I decided to walk the controls such that normal Windows enter key behaviour could be implemented. So my handler looks like this:

    Qt Code:
    1. void TextEdit::keyPressEvent(QKeyEvent * in_pEvent)
    2. {
    3. switch (in_pEvent->key())
    4. {
    5. case Qt::Key_Return:
    6. case Qt::Key_Enter:
    7. {
    8. // Find next button in tab order
    9. QPushButton * pButton = NULL;
    10. while (!pButton)
    11. {
    12. focusNextChild();
    13. pButton = dynamic_cast<QPushButton *>(parentWidget()->focusWidget());
    14. }
    15.  
    16. // Click the button
    17. pButton->click();
    18.  
    19. // Restore the focus
    20. setFocus();
    21. break;
    22. }
    23.  
    24. default:
    25. QTextEdit::keyPressEvent(in_pEvent);
    26. }
    27. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. QPlainTextEdit
    By deeee in forum Qt Programming
    Replies: 1
    Last Post: 27th May 2010, 02:05
  2. QplainTextEdit
    By deeee in forum Qt Programming
    Replies: 6
    Last Post: 27th May 2010, 01:14
  3. QPlainTextEdit
    By Carlsberg in forum Qt Programming
    Replies: 4
    Last Post: 13th June 2009, 07:12
  4. Shortcut
    By Voldemort in forum Qt Programming
    Replies: 16
    Last Post: 2nd May 2007, 21:51
  5. Trying to set shortcut
    By mikro in forum Newbie
    Replies: 2
    Last Post: 30th November 2006, 10:55

Tags for this Thread

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.