OS: Ubuntu Linux 8.10 x64
QT version: 4.4.3
The code:
#include <QApplication>
#include <QHttp>
#include <QString>
#include <iostream>
{
Q_OBJECT
public:
{
connect(&objQHttp, SIGNAL(dataReadProgress(int, int)), this, SLOT(DisplayProgress(int, int)));
objQHttp.get("/linux/ubuntu-releases/intrepid/ubuntu-8.10-desktop-amd64.iso");
}
private slots:
void DisplayProgress(int done, int total)
{
std::cout<< done<< " of "<< total<< " has been downloaded so far\n";
}
};
int main(int argc, char *argv[])
{
Test obj(0);
app.exec();
return 0;
}
#include <QApplication>
#include <QHttp>
#include <QString>
#include <iostream>
class Test: public QObject
{
Q_OBJECT
QHttp objQHttp;
public:
Test(QObject *parent= 0): QObject(parent), objQHttp("ftp.otenet.gr")
{
connect(&objQHttp, SIGNAL(dataReadProgress(int, int)), this, SLOT(DisplayProgress(int, int)));
objQHttp.get("/linux/ubuntu-releases/intrepid/ubuntu-8.10-desktop-amd64.iso");
}
private slots:
void DisplayProgress(int done, int total)
{
std::cout<< done<< " of "<< total<< " has been downloaded so far\n";
}
};
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
Test obj(0);
app.exec();
return 0;
}
To copy to clipboard, switch view to plain text mode
with QT+= network added in the .pro file, produces:
john@ubuntu:~/Projects/qt/test$ make
g++ -Wl,--no-undefined -o test main.o -L/usr/lib -lQtGui -lQtNetwork -lQtCore -lpthread
main.o: In function `main':
main.cpp:(.text+0x77): undefined reference to `vtable for Test'
main.cpp:(.text+0x117): undefined reference to `vtable for Test'
main.o: In function `Test::~Test()':
main.cpp:(.text._ZN4TestD1Ev[Test::~Test()]+0x14): undefined reference to `vtable for Test'
collect2: ld returned 1 exit status
make: *** [test] Error 1
john@ubuntu:~/Projects/qt/test$ make
g++ -Wl,--no-undefined -o test main.o -L/usr/lib -lQtGui -lQtNetwork -lQtCore -lpthread
main.o: In function `main':
main.cpp:(.text+0x77): undefined reference to `vtable for Test'
main.cpp:(.text+0x117): undefined reference to `vtable for Test'
main.o: In function `Test::~Test()':
main.cpp:(.text._ZN4TestD1Ev[Test::~Test()]+0x14): undefined reference to `vtable for Test'
collect2: ld returned 1 exit status
make: *** [test] Error 1
To copy to clipboard, switch view to plain text mode
How can this be fixed?
Bookmarks