Results 1 to 3 of 3

Thread: keyPressEvent not catching regular keys

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2014
    Posts
    59
    Thanks
    7
    Qt products
    Qt5
    Platforms
    Windows

    Default keyPressEvent not catching regular keys

    I am working on a simple text editor and am trying to catch a few keys, like "[" so I can add in "]" automatically. The handler only fire on special keys like shift, ctrl, f*. I slimmed my code down to this to test when it was not working:
    Qt Code:
    1. void Editor::keyPressEvent(QKeyEvent *evt)
    2. {
    3. qDebug() << "Key pressed";
    4. }
    To copy to clipboard, switch view to plain text mode 
    The characters are printed in the plainTextEdit correctly, but I only get qDebug output for special keys, like I mentioned. I have never had this problem before, in Qt or regular console programs, and my searches turn up the opposite problem. Any ideas on where to look would be a great help.

    <edit>
    I am using QSyntaxHighlighter in a separate class, could that be what is interfering?
    </edit>
    Last edited by admkrk; 12th March 2016 at 03:19.

Similar Threads

  1. some keys are not working(keyPressEvent)
    By sanjeet in forum Qt for Embedded and Mobile
    Replies: 2
    Last Post: 12th January 2018, 21:38
  2. Catching exceptions with Qt
    By The_Fallen in forum Qt Programming
    Replies: 6
    Last Post: 30th July 2010, 19:39
  3. Qt - catching interrupts
    By rishid in forum Qt Programming
    Replies: 2
    Last Post: 5th February 2008, 14:17
  4. Handling of dead keys in keyPressEvent()
    By ghorwin in forum Qt Programming
    Replies: 4
    Last Post: 2nd December 2006, 12:26
  5. Catching X Events
    By nupul in forum Qt Programming
    Replies: 3
    Last Post: 16th April 2006, 12:43

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.