Results 1 to 2 of 2

Thread: `QObject' is an ambiguous base of `ClientThread'

  1. #1
    Join Date
    Jan 2006
    Posts
    185
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default `QObject' is an ambiguous base of `ClientThread'

    I have this class

    Qt Code:
    1. #include <QTcpSocket>
    2. #include <QTextBrowser>
    3. #include "clientthread.h"
    4.  
    5. ClientThread::ClientThread(int socketDescriptor)
    6. {
    7. _socketDescriptor = socketDescriptor;
    8. textBrowser = new QTextBrowser(this);
    9. setWindowTitle("Server version 0.9 beta");
    10. setCentralWidget(textBrowser);
    11. setFixedSize(400,400);
    12. show();
    13. run();
    14.  
    15. }
    16.  
    17.  
    18. void ClientThread::run()
    19. {
    20. tcpSocket = new QTcpSocket();
    21. if(!tcpSocket->setSocketDescriptor(_socketDescriptor))
    22. textBrowser->append("Error in the connection");
    23. else
    24. textBrowser->append("Client successfully connected");
    25. iniConnection();
    26. exec();
    27. }
    28.  
    29.  
    30. void ClientThread::iniConnection()
    31. {
    32. connect(tcpSocket, SIGNAL(readyRead()), this, SLOT(readData()));
    33. }
    34.  
    35. void ClientThread::readData()
    36. {
    37.  
    38. }
    To copy to clipboard, switch view to plain text mode 


    When i try to compile it, I get this error:

    clientthread.cpp:33: error: `QObject' is an ambiguous base of `ClientThread'

    I know the error can be disabled in this lines

    Qt Code:
    1. void ClientThread::iniConnection()
    2. {
    3. connect(tcpSocket, SIGNAL(readyRead()), this, SLOT(readData()));
    4. }
    To copy to clipboard, switch view to plain text mode 

    The "connect" is the problem

    What is wrong ?
    Last edited by wysota; 7th December 2006 at 14:31. Reason: missing [code] tags

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: `QObject' is an ambiguous base of `ClientThread'

    Sounds like you are multi-inheriting QObject. That is not possible. Check for example this post.

    By the way, modifying widgets outside the main GUI thread is a no no:
    Qt Code:
    1. void ClientThread::run()
    2. {
    3. ...
    4. textBrowser->append("Error in the connection"); // !!
    5. ...
    6. textBrowser->append("Client successfully connected"); // !!
    7. ...
    8. }
    To copy to clipboard, switch view to plain text mode 

    It's documented here:
    Although QObject is reentrant, the GUI classes, notably QWidget and all its subclasses, are not reentrant. They can only be used from the main thread.
    Use signals and slots (queued connection) or custom events to cross the thread boundaries.
    J-P Nurmi

Similar Threads

  1. "ambiguous base" error
    By mhoover in forum Qt Programming
    Replies: 3
    Last Post: 14th June 2006, 00:49

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.