Results 1 to 9 of 9

Thread: Ctrl-C interception

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    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: Ctrl-C interception

    For a key event to be delivered you need to have an active widget that accepts focus. Then this key event is delivered to that widget and will be intercepted by the global event filter.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  2. #2
    Join Date
    Oct 2009
    Posts
    483
    Thanked 97 Times in 94 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Ctrl-C interception

    If you need a platform-independent way of solving your problem, you might need something like ncurses. If you are targeting POSIX-compliant systems, you may use QSocketNotifier to monitor input on stdin. This is a bit primitive, but it should work. For anything fancy I would recommend looking into ncurses (although I have never used it myself).

  3. #3
    Join Date
    Apr 2012
    Posts
    11
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Ctrl-C interception

    Quote Originally Posted by wysota View Post
    For a key event to be delivered you need to have an active widget that accepts focus. Then this key event is delivered to that widget and will be intercepted by the global event filter.
    Wysota, the application is a console app. There is no widget. Is it in this case impossible to intercept keystrokes with eventFilter?

    Quote Originally Posted by yeye_olive View Post
    If you need a platform-independent way of solving your problem, you might need something like ncurses. If you are targeting POSIX-compliant systems, you may use QSocketNotifier to monitor input on stdin. This is a bit primitive, but it should work. For anything fancy I would recommend looking into ncurses (although I have never used it myself).
    I'd rather not include another lib, but I will have look at QSocketNotifier to see if I understand how to use it to catch keystrokes. Whether it works or not: thanks for the suggestion!

  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: Ctrl-C interception

    Quote Originally Posted by T_h_e_o View Post
    Wysota, the application is a console app. There is no widget.
    Exactly. Thus you will not get any key events. You can use QSocketNotifier on STDIN to get line-buffered input notifications.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Apr 2012
    Posts
    11
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Ctrl-C interception

    Quote Originally Posted by wysota View Post
    Exactly. Thus you will not get any key events. You can use QSocketNotifier on STDIN to get line-buffered input notifications.
    Aha, now I understand the earlier reply from yeye_olive. I don't know the class QSocketNotifier, but I'll look things up (when I have time: I'm too busy to spend much time on this - it's a hobby project, but work prevails!).

    Thanks for the tip!

Similar Threads

  1. CTRL-+ in keyPressEvent
    By The_Fallen in forum Qt Programming
    Replies: 1
    Last Post: 12th May 2011, 22:40
  2. Interception of GET requests to the server
    By artkor in forum Newbie
    Replies: 4
    Last Post: 29th September 2010, 08:59
  3. filterout the Alt+Ctrl+Del
    By sudhansu in forum Qt Programming
    Replies: 6
    Last Post: 25th March 2010, 07:55
  4. disable ALT+CTRL+DEL!!!!
    By phillip_Qt in forum Qt Programming
    Replies: 10
    Last Post: 3rd November 2009, 09:23
  5. CTrl + A
    By navi1084 in forum Qt Programming
    Replies: 1
    Last Post: 23rd October 2008, 09:19

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.