Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to save QChart as image?

Tags:

qt

qchart

I have chart with differrent series. I need to save current ChartView as image. enter image description here I tried to do it as:

QPixmap p(this->size());
QImage* image= new QImage;
QPainter *painter= new QPainter(this);
chartView->render(painter);
if(!image->save("test.png"))
    qDebug()<<"ERROR";

I have next error: "QPainter::begin: Paint device returned engine == 0, type: 1"

like image 846
Konstantin Avatar asked Oct 17 '25 19:10

Konstantin


1 Answers

you can use grab and save functions

grap image and than save it

chartWidget.grab().save("test2.png")
like image 127
Rufai DEMIR Avatar answered Oct 20 '25 17:10

Rufai DEMIR



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!