qt - Multiple inheritance of QApplication and QAbstractNativeEventFilter -


i want filter usb device insert/removal events in qt application. need use installnativeeventfilter() install native filter (derived qabstractnativeeventfilter) app. problem need emit signals event filter, , connect them slots in app. so, if can inherent both qapplication , qabstractnativeeventfilter, both signals , slots in same class, , it's more convenient connect them. code below safe or not?

class qapp  : public qapplication, public qabstractnativeeventfilter {     virtual bool nativeeventfilter(const qbytearray &eventtype, void *message, long *) q_decl_override; signals:     void devicechanged();     ... };  qapp a(argc, argv); a.installnativeeventfilter( &a ); 

why want derive qapplication? emit signals, need derive qobject:

class nativeeventfilter : public qobject, public qabstractnativeeventfilter {   q_object   q_signal void signal1();   ... public:   explicit nativeeventfilter(qobject * parent = 0) : qobject(parent) {}   bool nativeeventfilter(const qbytearray & et, void * msg, long * result) q_decl_override {     ...   };   ... };  int main(int argc, char ** argv) {   qapplication app(argc, argv);   nativeeventfilter filter;   app.installnativeeventfilter(&filter);   ...   return app.exec(); } 

Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -