shoujo
(usa Slackware)
Enviado em 28/06/2017 - 19:41h
tentei fazer igual a pessoa postou nesse site
https://gist.github.com/alghanmi/c5d7b761b2c9ab199157
(Lembrando que ai eu so to chamando o site, ainda nao implementei as coisas que preciso)
Mas nao funcionou legal veja a modificacao que fiz
form1.h
#ifndef FORM1_H
#define FORM1_H
#include <QMainWindow>
#include <iostream>
#include <string>
#include <curl/curl.h>
using namespace std;
namespace Ui {
class Form1;
}
class Form1 : public QMainWindow
{
Q_OBJECT
public:
explicit Form1(QWidget *parent = 0);
string readBuffer;
CURL *curl;
CURLcode res;
size_t WriteCallback(void *contents, size_t size, size_t nmemb, void *userp)
{
((string*)userp)->append((char*)contents, size * nmemb);
return size * nmemb;
}
~Form1();
private slots:
void on_btnLogin_clicked();
private:
Ui::Form1 *ui;
};
#endif // FORM1_H
form1.cpp
#include "form1.h"
#include "ui_form1.h"
#include <QWebView>
#include <iostream>
#include <stdio.h>
#include <curl/curl.h>
#include <string>
using namespace std;
Form1::Form1(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::Form1)
{
ui->setupUi(this);
this->curl = curl_easy_init();
}
Form1::~Form1()
{
delete ui;
}
void Form1::on_btnLogin_clicked()
{
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, "http://www.google.com");
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
cout << readBuffer << std::endl;
}
dá o seguinte erro
form1.cpp:35: error: invalid use of member function (did you forget the '()' ?)
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
^