I got the solution, I just had to cast the the first parameter to (QObject*) and the example is working!
connect((QObject*) qWidget, SIGNAL(mouseMoveEvent1(QMouseEvent*)), this, SLOT(MouseMoveEvent(QMouseEvent*)));
BTW, is this the right way to do it? Should I use a static cast or something? Do let me know!
On Oct 25, 2008, at 2:27 PM, Elvis Dowson wrote:
I'm stuck at trying to set up a connection between a signal and a slot defined in the following classes. Could some one please let me know what I am doing wrong? It seems something to do with the types passed to the connect method. How can I fix this error? I want to connect QGraphicsView subclass to QVTKInteractor subclassed from QObject.
no matching function for call to 'QVTKInteractor::connect(QWidget*&, const char , QVTKInteractor* const, const char )'
note: candidates are: static bool QObject::connect(const QObject*, const char*, const QObject*, const char*, Qt::ConnectionType)
note: bool QObject::connect(const QObject*, const char*, const char*, Qt::ConnectionType) const
Here is what I am trying to do in a QVTKIteractor::SetupConnections() method
/*! Setup connections
void QVTKInteractor::SetupConnections(QWidget* qWidget, vtkRenderWindow* renWin)
// Set the QWidget instance associated with the interactor
QObject::connect(qWidget, SIGNAL(mouseMoveEvent1(QMouseEvent*)), this, SLOT(MouseMoveEvent(QMouseEvent*)));
Here are my classes:
class QVTKGraphicsView : public QGraphicsView
// Signal for mouse move events.
void mouseMoveEvent1(QMouseEvent* event);
// Overloaded virtual method for handling mouse events.
void mouseMoveEvent(QMouseEvent* event);
// D// Description:
// O// Overloaded virtual method for handling mouse move events.
void QVTKGraphicsView::mouseMoveEvent(QMouseEvent* event)
} } }
class QVTK_EXPORT QVTKInteractor : public QObject, public vtkRenderWindowInteractor
// Mouse move event slot
virtual void MouseMoveEvent(QMouseEvent* event);
/*! handle mouse move event
void QVTKInteractor::MouseMoveEvent(QMouseEvent* event)
vtkDebugMacro(<< " Mouse move event received!");
B Best regards,
W Elvis Dowson