Hi Guys, the QNAM in the code below returns an empty string regardless of what website I request.
#include "widget.h"
#include "ui_widget.h"
#include <QDebug>
ui(new Ui::Widget)
{
ui->setupUi(this);
nam = new QNetworkAccessManager(this);
}
Widget::~Widget()
{
delete ui;
}
void Widget::on_swipeBtn_clicked()
{
if(ui->urlLE->text().isEmpty())
{
msgBox.setText("URL field cannot be empty");
msgBox.exec();
}
else
{
connect(nam, &QNetworkAccessManager::finished, this, [this](QNetworkReply *reply){
//ui->htmlTB->setText(reply->readAll());
qDebug() << static_cast<QString>(reply->readAll()) <<endl;
});
nam
->get
(QNetworkRequest
(QUrl(ui
->urlLE
->text
().
simplified())));
}
}
#include "widget.h"
#include "ui_widget.h"
#include <QDebug>
Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
nam = new QNetworkAccessManager(this);
}
Widget::~Widget()
{
delete ui;
}
void Widget::on_swipeBtn_clicked()
{
if(ui->urlLE->text().isEmpty())
{
QMessageBox msgBox;
msgBox.setText("URL field cannot be empty");
msgBox.exec();
}
else
{
connect(nam, &QNetworkAccessManager::finished, this, [this](QNetworkReply *reply){
//ui->htmlTB->setText(reply->readAll());
qDebug() << static_cast<QString>(reply->readAll()) <<endl;
});
nam->get(QNetworkRequest(QUrl(ui->urlLE->text().simplified())));
}
}
To copy to clipboard, switch view to plain text mode
What could be causing this?
Bookmarks