PDA

View Full Version : connect fails to compile: reference to 'connect' is ambiguous



pospiech
9th May 2011, 10:03
I get the following error in this line:



void QMicosPolluxController::waitUntilPositionReached()
{
connect(d->checkPositionThread, SIGNAL(positionReached(bool)), this, SIGNAL(positionReached()));
}


The first class is derived from QThread, the second from QWidget.



QMicosPolluxController.cpp: In member function 'virtual void QMicosPolluxController::waitUntilPositionReached() ':
QMicosPolluxController.cpp:1047: error: reference to 'connect' is ambiguous
c:\Qt\SDK\2011.05\Desktop\Qt\4.7.3\mingw\include\Q tCore/qobject.h:313: error: candidates are: bool QObject::connect(const QObject*, const char*, const char*, Qt::ConnectionType) const
c:\Qt\SDK\2011.05\Desktop\Qt\4.7.3\mingw\include\Q tCore/qobject.h:198: error: candidates are: static bool QObject::connect(const QObject*, const char*, const QObject*, const char*, Qt::ConnectionType)
c:\Qt\SDK\2011.05\Desktop\Qt\4.7.3\mingw\include\Q tCore/qobject.h:313: error: bool QObject::connect(const QObject*, const char*, const char*, Qt::ConnectionType) const
c:\Qt\SDK\2011.05\Desktop\Qt\4.7.3\mingw\include\Q tCore/qobject.h:198: error: static bool QObject::connect(const QObject*, const char*, const QObject*, const char*, Qt::ConnectionType)


Half a year ago, the code compiled with Qt 4.6, now with 4.7.3 it does not. Has anything changed? At least I do not understand the error.

high_flyer
9th May 2011, 10:13
It looks like your QMicosPollControllerimplementes (or one of its non Qt base clases if it has any) or in a global scope somewhere also a 'connect()' function is implemented.
This should work:


void QMicosPolluxController::waitUntilPositionReached()
{
QObject::connect(d->checkPositionThread, SIGNAL(positionReached(bool)), this, SIGNAL(positionReached()));
}

pospiech
9th May 2011, 10:38
The error was caused by the derived class derived from QWidget and the base class derived from QObject. Deriving the base class from QWidget solved it.