Results 1 to 3 of 3

Thread: Implementing WndProc Override

  1. #1
    Join Date
    Apr 2009
    Posts
    11
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Implementing WndProc Override

    Hi,

    I am using QT 4.5. Currently I need to implement a sort of keyboard/mouse hook in my QT application. Essentially my application needs to listen for certain hotkeys even when it is not in focus. I read somewhere about RegisterRawInputDevices to allow my application to receive raw input from these devices, but in turn I need to override the WndProc method. Is there a way to do so in a QT application, or is there an equivalent way to implement the same feature using QT's API? Would be grateful for any advice. Thanks in advance.

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Implementing WndProc Override

    Its hard to tell exactly what you need based on what you wrote, and probably there are several ways to go about it.
    But you might want to check the following:
    bool QWidget::winEvent ( MSG * message, long * result )
    bool QCoreApplication::winEventFilter ( MSG * msg, long * result )
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Implementing WndProc Override

    RegisterRawInputDevices() seems a little overkill for handling a system-wide hotkey when a much more appropriate function called RegisterHotKey() exists. The later will also take a window handle as an argument and send that window a WM_HOTKEY message, which is much easier to process than overriding WndProc.

Similar Threads

  1. Override a signal
    By daviddoria in forum Newbie
    Replies: 4
    Last Post: 9th February 2010, 18:18
  2. override the default cursor
    By lytfyre in forum Qt Programming
    Replies: 2
    Last Post: 8th December 2008, 20:00
  3. ActiveQt: can I override lcid?
    By a550ee in forum Qt Programming
    Replies: 0
    Last Post: 3rd October 2007, 07:44
  4. override wheelEvent for QScrollBar
    By ChasW in forum Qt Programming
    Replies: 6
    Last Post: 25th January 2007, 09:50
  5. override minimumSize function
    By niko in forum Qt Programming
    Replies: 4
    Last Post: 30th October 2006, 05:28

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.