connect fails to compile: reference to 'connect' is ambiguous
I get the following error in this line:
Code:
void QMicosPolluxController::waitUntilPositionReached()
{
connect(d->checkPositionThread, SIGNAL(positionReached(bool)), this, SIGNAL(positionReached()));
}
The first class is derived from QThread, the second from QWidget.
Quote:
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.
Re: connect fails to compile: reference to 'connect' is ambiguous
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:
Code:
void QMicosPolluxController::waitUntilPositionReached()
{
QObject::connect(d
->checkPositionThread,
SIGNAL(positionReached
(bool)),
this,
SIGNAL(positionReached
()));
}
Re: connect fails to compile: reference to 'connect' is ambiguous
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.