Qt library, sub classing window to intercept messages?
I am, for the firs time, working with the Qt library. I am wondering if there is a way to subclass a Qt widget so you can intercept all the message passed to that widget, it's possibel with windows but I don't know how to do it, or if it is possible wi开发者_如何学Goth Qt? Is there an alternative?
The QWidget in question is of type Chat and is of type QList. How is it possible using the QWidget library to intercept anything which is added to a List, which is a widget?
Thanks.
Depends on what you mean by message. If you mean:
1 - events, I do believe there's an event handler you can override that is ultimately responsible for passing those events to the specific handler functions.
2 - signals, I have not tried it yet but it might be possible to override qt_metacall to behave in an utterly non-standard way. You will have to find a way to turn void** into something meaningful though and that's pretty damn tough without knowing exactly what you're responding to. There's an 'id' parameter that tells the MOC generated function what to do and then the rest is switches and reinterpret_casts.
3 - "message" in the object oriented sense where any call to a "method" is a "message". C++ doesn't work this way, sorry. If you want that kind of behavior you need something like Java or Objective-C.
精彩评论