Welcome, Guest. Please login or register.
Did you miss your activation email?

Author Topic: QChart  (Read 2397 times)

cwl

  • Newbie
  • *
  • Posts: 14
    • View Profile
QChart
« 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.

Arin Alex

  • Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 992
    • View Profile
Re: QChart
« Reply #1 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.

cwl

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: QChart
« Reply #2 on: December 05, 2018, 09:37:48 AM »
OK, thank you!

Arin Alex

  • Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 992
    • View Profile
Re: QChart
« Reply #3 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.


cwl

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: QChart
« Reply #4 on: December 13, 2018, 09:12:54 AM »
Excellent! Thank you very much! i will try it.