Results 1 to 9 of 9

Thread: handling XClientMessageEvent

  1. #1
    Join Date
    Aug 2007
    Posts
    4
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default handling XClientMessageEvent

    I'm new to Qt, so I apologize if this is a silly question.

    I'm using Qt on Linux. My application gets sent XClientMessageEvent from another application. How does Qt handle these events? Do they get converted to a QCustomEvent?

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: handling XClientMessageEvent

    Reimplement QWidget::x11Event(XEvent*) and catch it there.

    Regards

  3. #3
    Join Date
    Aug 2007
    Posts
    4
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: handling XClientMessageEvent

    What if I can't reimplement QWidget::x11Event since the widget is actually created by someone else - I simply get a pointer to a QWidget.

    My application (or rather library) has a QObject-derived class which holds a pointer to the QWidget and calls installEventFilter on it. I have reimplemented QObject::eventFilter, but from what I can see, that only works for QEvent, not XClientMessageEvent.

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: handling XClientMessageEvent

    J-P Nurmi

  5. #5
    Join Date
    Aug 2007
    Posts
    4
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: handling XClientMessageEvent

    Same problem - someone else creates QApplication as well!

  6. #6
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: handling XClientMessageEvent

    Could you be more specific?
    Do you have a library, or what?

    How do you use the QApplication that is already created by someone else?

    Regarding your QObject which you use as an event filter... Couldn't you turn it into a QWidget?

  7. #7
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: handling XClientMessageEvent

    I think QApplication::x11EventFilter() and QWidget::x11Event() are the only possibilities to access native X11 events. Further than that they get translated as Qt events.
    J-P Nurmi

  8. #8
    Join Date
    Aug 2007
    Posts
    4
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: handling XClientMessageEvent

    To clarify (hopefully):

    I am writing a library that someone else will link into their application. That someone else is the one who will create the QApplication and the QWidget (and any other GUI objects). They will simply pass the QWidget to my library. I have a QObject-derived class that calls installEventFilter on the QWidget that was passed to my library so I can grab the events I need. This works for all events (key and mouse input, focus, etc) except the XClientMessageEvent that also gets sent to the QWidget.

    Since Qt seems to translate all the other XEvents correctly, it just seems odd to me that it doesn't translate an XClientMessageEvent to a QCustomEvent as well.

  9. #9
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: handling XClientMessageEvent

    Quote Originally Posted by qtdev18 View Post
    I am writing a library that someone else will link into their application. That someone else is the one who will create the QApplication and the QWidget (and any other GUI objects). They will simply pass the QWidget to my library. I have a QObject-derived class that calls installEventFilter on the QWidget that was passed to my library so I can grab the events I need.
    I'm afraid there is no way for you to catch XClientMessageEvent within the described environment. Perhaps you could write a QApplication subclass which makes it possible for you to catch required native events. Then just demand end-users to instantiate your application object instead of QApplication. If they don't, the particular feature depending on XClientMessageEvent becomes disabled or so.

    This works for all events (key and mouse input, focus, etc) except the XClientMessageEvent that also gets sent to the QWidget.

    Since Qt seems to translate all the other XEvents correctly, it just seems odd to me that it doesn't translate an XClientMessageEvent to a QCustomEvent as well.
    The purpose of QCustomEvent is something completely different, namely user-defined events. I'm not so sure about "all the other XEvents" either.
    J-P Nurmi

Similar Threads

  1. Suggested Error Handling
    By Max Yaffe in forum Qt Programming
    Replies: 6
    Last Post: 15th July 2014, 17:29
  2. handling paintGL in a separate thread
    By al101 in forum Qt Programming
    Replies: 1
    Last Post: 15th May 2007, 17:04
  3. Exception handling in Qt 4.2.2
    By vishal.chauhan in forum Qt Programming
    Replies: 1
    Last Post: 27th February 2007, 09:47
  4. need help for tree Handling concept
    By jyoti in forum Qt Programming
    Replies: 5
    Last Post: 24th November 2006, 04:52
  5. Keyboard Handling
    By ToddAtWSU in forum Qt Programming
    Replies: 4
    Last Post: 5th July 2006, 13:25

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.