PDA

View Full Version : Getting Chart as picture



codeman
20th November 2009, 15:11
Hello friends,

my problem is with google chart api. When I create an chart with


http://chart.apis.google.com/chart?cht=p3&chd=t:60,40&chs=250x100&chl=Hello|World


I do right click on the picture to get the pie as image.

with php I can get it dynamically like this


<?php
file_put_contents('graph.png');
file_get_contents('http://chart.apis.google.com/chart?cht=p3&chd=t:60,40&chs=250x100&chl=Hello|World");
?>


Is there a way to get the image with QT classes ????

sadjoker
21st November 2009, 16:44
Http Request with all the data->Reply data result in QByteArray->convert data to pixmap->display

Simulate the process with Http debugger to see what is going on with the requests and replies and simulate it with Qt.

lasher
21st November 2009, 20:34
Hi

Try this



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);
}



Greetings!

codeman
23rd November 2009, 22:05
I will try it asap really thank you very much for this suggestion ;o))

codeman
24th November 2009, 13:39
Its works wow great thing..... thx thx thx thx