Hi! I have researched how to include QChart into limereport and I found that it will take a lot of time
Unfortunately, I do not have enough of it at the moment. But but I found a temporary solution to this problem
In the
develop branch I have added an external painting feature to ImageItem. You can use it to draw QChart item manually.
HOWTO:
1. make a slot for example
void slotExternalPainter(const QString& objectName, QPainter* painter, const QStyleOptionGraphicsItem*);
2. copnnect it to report engine to signal externalPaint(const QString&, QPainter*, const QStyleOptionGraphicsItem*)
connect(report, SIGNAL(externalPaint(const QString&, QPainter*, const QStyleOptionGraphicsItem*)),
this, SLOT(slotExternalPainter(const QString&, QPainter*, const QStyleOptionGraphicsItem*)));
3. paint QChart in that slot
jast for example
void MainWindow::slotExternalPainter(const QString& objectName, QPainter* painter, const QStyleOptionGraphicsItem* options)
if (objectName.compare("ImageItem1")==0){
m_chart->scene()->setSceneRect(QRectF(0,0,options->rect.width(), options->rect.height()));
m_chart->setGeometry(m_chart->scene()->sceneRect());
painter->save();
painter->setRenderHint(QPainter::Antialiasing);
m_chart->scene()->render(painter, options->rect);
painter->restore();
}
}
It's important to create QChartView and put QChart to it before rendering.
4. In a report's template put an ImageItem and activate useExternalPainter property in it.