Results 1 to 5 of 5

Thread: Getting Chart as picture

  1. #1
    Join Date
    Apr 2009
    Posts
    206
    Thanks
    34
    Thanked 2 Times in 2 Posts

    Default Getting Chart as picture

    Hello friends,

    my problem is with google chart api. When I create an chart with
    Qt Code:
    1. http://chart.apis.google.com/chart?cht=p3&chd=t:60,40&chs=250x100&chl=Hello|World
    To copy to clipboard, switch view to plain text mode 

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

    with php I can get it dynamically like this
    Qt Code:
    1. <?php
    2. file_put_contents('graph.png');
    3. file_get_contents('http://chart.apis.google.com/chart?cht=p3&chd=t:60,40&chs=250x100&chl=Hello|World");
    4. ?>
    To copy to clipboard, switch view to plain text mode 

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

  2. #2
    Join Date
    Feb 2008
    Posts
    50
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Getting Chart as picture

    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.

  3. The following user says thank you to sadjoker for this useful post:

    codeman (21st November 2009)

  4. #3
    Join Date
    Sep 2009
    Posts
    20
    Thanked 2 Times in 2 Posts

    Default Re: Getting Chart as picture

    Hi

    Try this

    Qt Code:
    1. Widget::Widget(QWidget *parent) : QWidget(parent), ui(new Ui::Widget)
    2. {
    3. ui->setupUi(this);
    4. http = new QHttp;
    5. chart = new QByteArray;
    6. QHttpRequestHeader header("POST", "/chart?cht=p3&chf=bg,s,65432100&chd=t:60,40&chs=250x100&chl=Hello|World");
    7. header.setValue("Host","chart.apis.google.com");
    8. http->setHost("chart.apis.google.com");
    9. http->request(header, *chart);
    10. QApplication::processEvents();
    11. connect(http, SIGNAL(done(bool)), this, SLOT(showChart()));
    12. }
    13.  
    14. void Widget::showChart()
    15. {
    16. *chart = http->readAll();
    17. QPixmap chartPixmap;
    18. chartPixmap.loadFromData(*chart);
    19. ui->label->setPixmap(chartPixmap);
    20. }
    To copy to clipboard, switch view to plain text mode 


    Greetings!

  5. #4
    Join Date
    Apr 2009
    Posts
    206
    Thanks
    34
    Thanked 2 Times in 2 Posts

    Default Re: Getting Chart as picture

    I will try it asap really thank you very much for this suggestion ;o))

  6. #5
    Join Date
    Apr 2009
    Posts
    206
    Thanks
    34
    Thanked 2 Times in 2 Posts

    Default Re: Getting Chart as picture

    Its works wow great thing..... thx thx thx thx

Similar Threads

  1. Draw a bar chart inisde the QScrollArea
    By ultrasonic in forum Qt Programming
    Replies: 6
    Last Post: 9th August 2012, 20:06
  2. Print RichText and a scaled Picture
    By kray in forum Qt Programming
    Replies: 1
    Last Post: 29th December 2008, 20:56
  3. wait copy picture then show it
    By raphaelf in forum Newbie
    Replies: 6
    Last Post: 5th November 2006, 12:09
  4. QPixmap/QImage How to enlarge a picture
    By jcr in forum Qt Programming
    Replies: 1
    Last Post: 22nd June 2006, 06:38

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.