philwinder
15th November 2008, 20:35
Hi again,
I'm having problems connecting to a class that does not have a pointer.
I created an instance of a class and I thought that I didn't need it to be a pointer, so I will just create the object in my header file. But when I attempt to connect a signal from that instance the compiler throws an error:
xBeeComms comms(); // Object
...
connect( &comms, SIGNAL( dataReceived( QbyteArray * ) ), this, SLOT( receivedData( QByteArray * ) ) ); // In the constructor
The error I get is:
ISO C++ forbids taking the address of an unqualified or parenthesized non-static member function to form a pointer to member function. Say ‘&messageGenerator::comms’
So I change the code to:
connect( &messageGenerator::comms, SIGNAL( dataReceived( QbyteArray * ) ), this, SLOT( receivedData( QByteArray * ) ) );
And I now get the error:
error: no matching function for call to ‘messageGenerator::connect(xBeeComms (messageGenerator::*)(), const char [30], messageGenerator* const, const char [30])’
Any idea's how to get it working?
I'm having problems connecting to a class that does not have a pointer.
I created an instance of a class and I thought that I didn't need it to be a pointer, so I will just create the object in my header file. But when I attempt to connect a signal from that instance the compiler throws an error:
xBeeComms comms(); // Object
...
connect( &comms, SIGNAL( dataReceived( QbyteArray * ) ), this, SLOT( receivedData( QByteArray * ) ) ); // In the constructor
The error I get is:
ISO C++ forbids taking the address of an unqualified or parenthesized non-static member function to form a pointer to member function. Say ‘&messageGenerator::comms’
So I change the code to:
connect( &messageGenerator::comms, SIGNAL( dataReceived( QbyteArray * ) ), this, SLOT( receivedData( QByteArray * ) ) );
And I now get the error:
error: no matching function for call to ‘messageGenerator::connect(xBeeComms (messageGenerator::*)(), const char [30], messageGenerator* const, const char [30])’
Any idea's how to get it working?