c++ - Emit signal from non-member static function -
I tried to use QThread for the first time and I used to emit signals from non-member I want to have constant function
My
DataReceiver.h file:.
#ifndef DATARECEIVER_H #define DATARECEIVER_H # Include & lt; QObject & gt; #include "vrpn_Analog.h" Class DataReceiver: Public QObject {Q_OBJECT Public: DatareEcever (); Public slots: zero checks (); Signal: zero blink (); }; Zero VRPN_CALLBACK hand_anolog (zero * userdata, const vrpn_ANALOGCB A); #endif // DATARECEIVER_H My DataReceiver.cpp file:
#include "datareceiver.h" #include "vrpn_Analog ". H "DetectorIcever :: DatareEcever () {} Zero Dataraisever :: Check () {bool running = true; / * VRPN Analog Object * / vrpn_Analog_Remote * VRPNAnalog; / * Binding for VRPN analog for a callback * / VRPN LogLog = New VRPN_Annog_remote ("OpenVee_BriPN_Anlog @LocalHost"); VRPNAnLog-> Register_Change_Handler (NULL, HandelNellogg); / * The main loop of the program, each VRPN object has to be asked to process the data. Should be / when (on) {VRPNAnalog-> Menloop ();}} zero VRPN_CALLBACK handle_analog (Zero * UserData, constant vrpn_ANALOGCB) {for (I int = 0; I & lt; a.num_channel; i ++ ) {If (a.channel [i]> 0) {throwing nap ();}}} in handle_analog to signal the emission I try, which I want to use in any other category.
MainWindow :: checkChannels () {QThread * thread = new qthread; dataricevar * data receiver = new data receiver (); DataReceiver-> MoveToThread (thread); // connect (thread, signal (blu Sk ()), this, slot (Next image ())); thread-> Start (); } But when I try to run I receive an error:
Error: C2352: 'Dataciceeer :: Blink': non-static Invalid call function of the member
I know where my fault is, but I do not know how to fix it.
It is not meant to emit a signal without signaling it without any similar objects, because You have nothing to connect to it.
Whatever you want to pass in your DataReceiver as an indicator in userData , and apply a public method that Emits the signal, then you can put userData in the DataReceiver and call the method on it.
What do I mean to try the following incomplete code
Zero DataReceiver :: emitBlink () {// Definitely also should be added in the header. Eyelid (emitted); } ... /// userdata VRPNAnalog- "account_change_handler" (this, as hand_analog) pass in "this"; ... zero VRPN_CALLBACK handle_analog (Zero * UserData, constant vrpn_ANALOGCB a) {... reinterpret_cast & lt; DataReceiver * & gt; (UserData) - & gt; EmitBlink (); ...}
Comments
Post a Comment