i'm new to QT API and the QT IDE, i was following this tutorial: http://developer.nokia.com/community/wiki/Creating_an_HTTP_network_request_in_Qt, but when i try to compile i get this errors, the usually cause of the problem is: the compiler couldn't find the .cpp/.lib archive where the code for the methods are, but in this case, the api would be already configured, i can't understand why i'm getting this error, and also i couldn't find the project properties, here is my test code:
#include <QMainWindow>
#include <QUrl>
#include <QtNetwork/QNetworkAccessManager>
#include <QtNetwork/QNetworkRequest>
#include <QtNetwork/QNetworkReply>
this is the headers included on the mainwindow.hpp file, now the mainwindow.cpp:
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
QNetworkAccessManager* nam;
nam = new QNetworkAccessManager(this);
QObject::connect(nam, SIGNAL(finished(QNetworkReply*)),
this, SLOT(finishedSlot(QNetworkReply*)));
QUrl url("http://www.forum.nokia.wiki");
QNetworkReply* reply = nam->get(QNetworkRequest(url));
}
finishedSlot method:
void MainWindow::finishedSlot(QNetworkReply* reply)
{
//nothing
}
so this is the code, if someone can help i'll thank you :)
Do you have QT += network
in the .pro project file?
Edit: fixed typo, was config instead of QT
I solved this for CMake by appending following lines to the CMakeLists.txt:
find_package(Qt5Network REQUIRED)
target_link_libraries(${PROJECT_NAME} Qt5::Network)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With