Reputation: 11944
I want to receive custom messages in Qt via the QAbstractNativeEventFilter. Basically I added a switch WM_USER + 1:
in the implementation, but I get notifications even though I am not sending anything. I assume that Qt could be using user messages internally as well. Is there a way to know the last id QT is using so that I can use the first free?
Upvotes: 0
Views: 2004
Reputation: 11588
The WM_USER
range of messages is owned by the code that called RegisterClass()
. In this case, that would be Qt, which is using that range for its own purposes. You will have to consult the Qt documentation to see what range of messages are available for you to use. This might be the WM_APP
range, but if Qt uses that as well (and doesn't provide a way for you to request a message to use), you'll have to deal with registered window messages and their shortcomings. Again, check the Qt documentation.
EDIT, since I wasn't clear enough the first time
Do NOT try to find some random WM_USER + n
that you can use. The point of the link I put there is that Qt is free to use all of the WM_USER
messages for whatever it wants. Ignore this and your code will break in a future version of Qt. You must consult Qt documentation to see whether Qt specifically defines a set of messages in the WM_APP
range (or even in the WM_USER
range, but this must be explicitly stated in the documentation) as safe to use, and if not, you have no choice but to call RegisterWindowMessage()
to register a system-wide named message. Ask on the Qt mailing list if necessary. Checking the source is not going to work because the current source is not a contract for future versions of Qt.
Upvotes: 6