ich probiere mit Eclipse (3.3), CDT (4) und QT4 ein Programm zu schreiben, was einige Netzwerkverbindungen aufbaut.
Dazu habe ich die QtNetwork eingebunden.
Meine Headerdatei sieht folgendermaßen aus:
Code: Alles auswählen
#ifndef NETWORKLIB_H_
#define NETWORKLIB_H_
// --------------------------------------------------------
// Includes -
// --------------------------------------------------------
#include "_tycs.h"
#include "inifile.h"
#include </usr/include/qt4/QtNetwork/QTcpSocket>
#include </usr/include/qt4/QtNetwork/QtNetwork>
// --------------------------------------------------------
// Class -
// --------------------------------------------------------
class MyNetwork : public QTcpSocket
{
Q_OBJECT;
public:
QTcpSocket tcpSocket;
int nextBlockSize;
public:
MyNetwork();
public slots:
void tcpConnected();
void tcpDisconnected();
void tcpRead();
void tcpError();
};
#endif /*NETWORKLIB_H_*/
Code: Alles auswählen
// --------------------------------------------------------
// Includes -
// --------------------------------------------------------
#include "networkLib.h"
#include "inifile.h"
#include "typeDefs.h"
#include <iostream>
MyNetwork::MyNetwork()
{
connect ( &tcpSocket,
SIGNAL(connected()),
this,
SLOT(tcpConnected()));
connect ( &tcpSocket,
SIGNAL(disconnected()),
this,
SLOT(tcpDisconnected()));
connect ( &tcpSocket,
SIGNAL(readyRead()),
this,
SLOT(tcpRead()));
connect ( &tcpSocket,
SIGNAL(error(QAbstractSocket::SocketError)),
this,
SLOT(tcpError()));
tcpSocket.connectToHost("xxx", 21);
}
void MyNetwork::tcpConnected()
{
std::cout << "Connected successfully";
std::cout.flush();
}
void MyNetwork::tcpDisconnected()
{
std::cout << "Disconnected successfully";
std::cout.flush();
}
void MyNetwork::tcpRead()
{
std::cout << "Read\n";
std::cout.flush();
char buf[512];
int read_ret = 0;
if (tcpSocket.bytesAvailable() != 0)
{
read_ret = tcpSocket.read(buf, 512);
printf("received[%i] '%s'\n", read_ret, buf);
}
QString nextFortune;
QDataStream in(&tcpSocket);
in.setVersion(QDataStream::Qt_4_0);
if (nextBlockSize == 0)
{
temp = tcpSocket.bytesAvailable();
in >> nextFortune;
}
std::cout << nextFortune << "\n";
std::cout << temp;
std::cout.flush();*/
}
void MyNetwork::tcpError()
{
std::cout << "Error";
std::cout.flush();
}
int main()
{
std::cout << "test";
MyNetwork *nw = new MyNetwork();
return 0;
}
Code: Alles auswählen
undefined reference to `vtable for MyNetwork' Code: Alles auswählen
Object::connect: No such slot QTcpSocket::tcpConnected()
Object::connect: No such slot QTcpSocket::tcpDisconnected()
Object::connect: No such slot QTcpSocket::tcpRead()
Object::connect: No such slot QTcpSocket::tcpError()Ich hoffe Ihr könnt mir helfen.
Gruß
Michael