Results 1 to 13 of 13

Thread: Problems with recieving Windows messages using winEvent

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Problems with recieving Windows messages using winEvent

    I guess you'd have to install a hook using WinAPI calls. This is really out of scope of this forum.
    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
    May 2011
    Posts
    9
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    2

    Default Re: Problems with recieving Windows messages using winEvent

    Thank you again. Guess I can only hope that in future relases of Qt there will be a new function added that will allow it in easy way.

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Problems with recieving Windows messages using winEvent

    Why double a function that already exists?
    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.


  4. #4
    Join Date
    May 2011
    Posts
    9
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    2

    Default Re: Problems with recieving Windows messages using winEvent

    If you mean hooks... well... I don't like it. I started creating in qt because I can't stand structure of WinApi...

    I think about using QAbstractEventDispatcher in my program. If I get some free-time I'll look into doc and try to work with it.

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Problems with recieving Windows messages using winEvent

    I don't see how this would help. You want to intercept messages that are not meant for you, your application won't receive them unless you explicitly request that by installing a hook in Windows message loop.
    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.


  6. #6
    Join Date
    May 2011
    Posts
    9
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    2

    Default Re: Problems with recieving Windows messages using winEvent

    QAbstractEventDispatcher Doc
    An event dispatcher receives events from the window system and other sources. It then sends them to the QCoreApplication or QApplication instance for processing and delivery.
    The event filter function set here is called for all messages taken from the system event loop before the event is dispatched to the respective target, including the messages not meant for Qt objects.
    That looks fine for me. If I understand correctly it can do the work that hooks do. Still, I have a problem with implementing it into my code... Guess, I have to try again...
    Last edited by rbrafi; 1st June 2011 at 22:39.

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Problems with recieving Windows messages using winEvent

    It doesn't say anything about events meant for other applications.
    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.


  8. #8
    Join Date
    May 2011
    Posts
    9
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    2

    Default Re: Problems with recieving Windows messages using winEvent

    Ugh... You are right... I'm assuming that "messages not meant for Qt objects" are messages for other applications and I am probably wrong. Just in case I want to give it a try...

    I have problem (again ) with using Event Dispatcher.

    My MainWindow constructor:
    Qt Code:
    1. ui->setupUi(this);
    2. QAbstractEventDispatcher::EventFilter MyEventFilter;
    3. QAbstractEventDispatcher *eventDispatcher = QAbstractEventDispatcher::instance();
    4. eventDispatcher->setEventFilter(MyEventFilter);
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. bool MainWindow::MyEventFilter(MSG *message)
    2. {
    3. switch(message->message)
    4. {
    5. case WM_KEYDOWN:
    6. qDebug("KEYDOWN");
    7. switch(message->wParam)
    8. {
    9. case 0x41 :
    10. qDebug("- A");
    11. break;
    12.  
    13. case VK_F12 :
    14. qDebug("- F12");
    15. break;
    16. default:
    17. break;
    18. }
    19. break;
    20. default:
    21. return false;
    22. }
    23. return false;
    24. }
    To copy to clipboard, switch view to plain text mode 

    Errorlog:
    Qt Code:
    1. In constructor 'MainWindow::MainWindow(QWidget*):
    2. warning:'MyEventFilter' may be used uninitialized in this function
    3. In constructor 'MainWindow::MainWindow(QWidget*):
    4. warning:'MyEventFilter' may be used uninitialized in this function
    To copy to clipboard, switch view to plain text mode 
    It runs, but crashes.

    How should I initialize MyEventFilter? I tried couple of times but effects were even worse than that...

  9. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Problems with recieving Windows messages using winEvent

    QAbstractEventDispatcher::EventFilter is supposed to be a function and you are using it as a variable.
    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.


  10. The following user says thank you to wysota for this useful post:

    rbrafi (6th June 2011)

  11. #10
    Join Date
    May 2011
    Posts
    9
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    2

    Default Re: Problems with recieving Windows messages using winEvent

    I decided that it is better to use RegisterHotKey() function from winApi. It saves a lot of time in my case. Still, I feel unsatisfied for some reason Thank you for your advices. They helped a lot.

Similar Threads

  1. PyQt - QGraphicsItem not recieving mouse events
    By megamic in forum Qt Programming
    Replies: 3
    Last Post: 4th April 2011, 10:14
  2. Replies: 1
    Last Post: 12th January 2009, 18:05
  3. problem with Recieving grayscale
    By navi1084 in forum Qt Programming
    Replies: 1
    Last Post: 27th September 2008, 22:51
  4. recieving QProcess::write data
    By node_ex in forum Qt Programming
    Replies: 3
    Last Post: 28th July 2008, 12:18
  5. Windows focus / Windows Shutdown Problems
    By December in forum Qt Programming
    Replies: 6
    Last Post: 22nd October 2007, 14:10

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.