Results 1 to 3 of 3

Thread: ambiguous connect()

  1. #1
    Join Date
    Jan 2009
    Location
    Germany
    Posts
    387
    Thanks
    101
    Thanked 15 Times in 15 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default ambiguous connect()

    Hello,

    I don't quite know how to deal with this compiler error. I have a class that is a QWidget and a QThread at the same time. I'm using the thread to load a large file in the background. The progress bar on the widget should indicate how far the file is loaded. Here is the code:

    Qt Code:
    1. Visualizer3D::Visualizer3D(QWidget *parent)
    2. : QWidget(parent), QThread(parent)
    3. {
    4. ui.setupUi(this);
    5.  
    6. connect(this, SIGNAL(fileLoadingProgress(int)), ui.progressBar, SLOT(valueChanged(int))); // <-- this fails
    7.  
    8. start();
    9. }
    10.  
    11. void Visualizer3D::run()
    12. {
    13. QFile file("data.dat");
    14. file.open(QIODevice::ReadOnly);
    15. QDataStream in(&file);
    16. for (unsigned int i = 0; i < LINECOUNT; i++)
    17. {
    18. emit fileLoadingProgress((int)(100*i/LINECOUNT));
    19. }
    20. file.close();
    21. }
    To copy to clipboard, switch view to plain text mode 

    And then it tells me:
    visualizer3d.cpp:22: error: reference to ‘connect’ is ambiguous
    ../../qtsdk-2009.03/qt/include/QtCore/qobject.h:307: error: candidates are: bool QObject::connect(const QObject*, const char*, const char*, Qt::ConnectionType) const
    ../../qtsdk-2009.03/qt/include/QtCore/qobject.h:202: error: candidates are: static bool QObject::connect(const QObject*, const char*, const QObject*, const char*, Qt::ConnectionType)
    ../../qtsdk-2009.03/qt/include/QtCore/qobject.h:307: error: bool QObject::connect(const QObject*, const char*, const char*, Qt::ConnectionType) const
    ../../qtsdk-2009.03/qt/include/QtCore/qobject.h:202: error: static bool QObject::connect(const QObject*, const char*, const QObject*, const char*, Qt::ConnectionType)

    Please help?

    Cruz

  2. #2
    Join Date
    Aug 2006
    Posts
    221
    Thanks
    3
    Thanked 29 Times in 19 Posts

    Default Re: ambiguous connect()

    QWidget inherits QObject and QThread inherits QObject so which QObject should the poor connect use? You cannot multiple inherit from more than one QObject class.

  3. #3
    Join Date
    Dec 2008
    Location
    TaganrogNativelandChehov,Russia
    Posts
    64
    Thanks
    1
    Thanked 8 Times in 7 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: ambiguous connect()

    Are you sure that you can write that:
    QWidget(parent), QThread(parent) ???
    There are 2 QObject object in this class.
    I think its wrong.
    east or west home is best

Similar Threads

  1. Connect Problem
    By nrabara in forum Newbie
    Replies: 3
    Last Post: 4th May 2009, 12:19
  2. Application only 'animates' once
    By arkain in forum Qt Programming
    Replies: 7
    Last Post: 29th April 2009, 08:09
  3. A signal/slot connect isn't working.
    By Daimonie in forum Qt Programming
    Replies: 6
    Last Post: 15th February 2009, 22:55
  4. Replies: 5
    Last Post: 28th August 2006, 14:36

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.