Results 1 to 3 of 3

Thread: connect fails to compile: reference to 'connect' is ambiguous

  1. #1
    Join Date
    Feb 2008
    Posts
    157
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default connect fails to compile: reference to 'connect' is ambiguous

    I get the following error in this line:


    Qt Code:
    1. void QMicosPolluxController::waitUntilPositionReached()
    2. {
    3. connect(d->checkPositionThread, SIGNAL(positionReached(bool)), this, SIGNAL(positionReached()));
    4. }
    To copy to clipboard, switch view to plain text mode 

    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.
    Last edited by high_flyer; 9th May 2011 at 11:11. Reason: code tags

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default 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:
    Qt Code:
    1. void QMicosPolluxController::waitUntilPositionReached()
    2. {
    3. QObject::connect(d->checkPositionThread, SIGNAL(positionReached(bool)), this, SIGNAL(positionReached()));
    4. }
    To copy to clipboard, switch view to plain text mode 
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Feb 2008
    Posts
    157
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default 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.

Similar Threads

  1. Replies: 4
    Last Post: 28th May 2011, 22:57
  2. Replies: 12
    Last Post: 30th December 2010, 11:37
  3. Replies: 16
    Last Post: 16th February 2010, 14:17
  4. ambiguous connect()
    By Cruz in forum Qt Programming
    Replies: 2
    Last Post: 27th August 2009, 12:35
  5. Replies: 4
    Last Post: 10th November 2006, 16:38

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.