`QObject' is an ambiguous base of `ClientThread'
I have this class
Code:
#include <QTcpSocket>
#include <QTextBrowser>
#include "clientthread.h"
ClientThread::ClientThread(int socketDescriptor)
{
_socketDescriptor = socketDescriptor;
setWindowTitle("Server version 0.9 beta");
setCentralWidget(textBrowser);
setFixedSize(400,400);
show();
run();
}
void ClientThread::run()
{
if(!tcpSocket->setSocketDescriptor(_socketDescriptor))
textBrowser->append("Error in the connection");
else
textBrowser->append("Client successfully connected");
iniConnection();
exec();
}
void ClientThread::iniConnection()
{
connect(tcpSocket, SIGNAL(readyRead()), this, SLOT(readData()));
}
void ClientThread::readData()
{
}
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
Code:
void ClientThread::iniConnection()
{
connect(tcpSocket, SIGNAL(readyRead()), this, SLOT(readData()));
}
The "connect" is the problem
What is wrong ?
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:
Code:
void ClientThread::run()
{
...
textBrowser->append("Error in the connection"); // !!
...
textBrowser->append("Client successfully connected"); // !!
...
}
It's documented here:
Quote:
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.