LimeReport Forum

General Category | Основное => Discussion | Обсуждение => Topic started by: cwl on December 04, 2018, 09:12:04 AM

Title: QChart
Post by: cwl on December 04, 2018, 09:12:04 AM
Hi Alex, could current version add a QChart on report, and without distortion when zoom in, thank you! Looking forward for your reply.
Title: Re: QChart
Post by: Arin Alex on December 04, 2018, 04:46:00 PM
At the moment it's not possible. It will take some time. I will inform you when it is possible.
Title: Re: QChart
Post by: cwl on December 05, 2018, 09:37:48 AM
OK, thank you!
Title: Re: QChart
Post by: Arin Alex on December 12, 2018, 11:51:44 PM
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
Code: [Select]
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.

Title: Re: QChart
Post by: cwl on December 13, 2018, 09:12:54 AM
Excellent! Thank you very much! i will try it.