{
ui->setupUi(this);
QHttpRequestHeader header
("POST",
"/chart?cht=p3&chf=bg,s,65432100&chd=t:60,40&chs=250x100&chl=Hello|World");
header.setValue("Host","chart.apis.google.com");
http->setHost("chart.apis.google.com");
http->request(header, *chart);
connect(http, SIGNAL(done(bool)), this, SLOT(showChart()));
}
void Widget::showChart()
{
*chart = http->readAll();
chartPixmap.loadFromData(*chart);
ui->label->setPixmap(chartPixmap);
}
Widget::Widget(QWidget *parent) : QWidget(parent), ui(new Ui::Widget)
{
ui->setupUi(this);
http = new QHttp;
chart = new QByteArray;
QHttpRequestHeader header("POST", "/chart?cht=p3&chf=bg,s,65432100&chd=t:60,40&chs=250x100&chl=Hello|World");
header.setValue("Host","chart.apis.google.com");
http->setHost("chart.apis.google.com");
http->request(header, *chart);
QApplication::processEvents();
connect(http, SIGNAL(done(bool)), this, SLOT(showChart()));
}
void Widget::showChart()
{
*chart = http->readAll();
QPixmap chartPixmap;
chartPixmap.loadFromData(*chart);
ui->label->setPixmap(chartPixmap);
}
To copy to clipboard, switch view to plain text mode
Bookmarks