Hi, 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!
Best regards,
Elvis Dowson
On Oct 25, 2008, at 2:27 PM, Elvis Dowson wrote: Hi, 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.
/Users/elvis/Project/C4I/Source/cxx/vtkOffScreenRenderingCarbonTest/QVTKInteractor.cpp:107: error: no matching function for call to 'QVTKInteractor::connect(QWidget*&, const char [31], QVTKInteractor* const, const char [30])' /Developer/Applications/Qt-4.4.3/lib/QtCore.framework/Versions/4/Headers/qobject.h:197: note: candidates are: static bool QObject::connect(const QObject*, const char*, const QObject*, const char*, Qt::ConnectionType) /Developer/Applications/Qt-4.4.3/lib/QtCore.framework/Versions/4/Headers/qobject.h:302: 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 {
Q_OBJECT Q_SIGNALS: // Description: // Signal for mouse move events. void mouseMoveEvent1(QMouseEvent* event);
// Description: // 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) { { { emit mouseMoveEvent1(event); QGraphicsView::mouseMoveEvent(event); } } }
} class QVTK_EXPORT QVTKInteractor : public QObject, public vtkRenderWindowInteractor {{ { Q_OBJECT pub
public Q_SLOTS:
// 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
cx
|