[Kmymoney-devel] Chart on the home page

Thomas Baumgart thb at net-bembel.de
Fri Oct 23 13:15:28 CEST 2009


On Friday 23 October 2009 12:56:30 Alvaro Soliverez wrote:
> Hello all,
> I just commited a big refactor of charts which I have been working on for
> the past weeks.
>
> There is still a missing functionality, which is to show the charts on the
> home page.
>
> Here is the relevant code, from khomeview.cpp
>
> QPixmap pm = QPixmap::grabWidget(chartWidget->coordinatePlane()->parent(),
> QRect(QPoint(0, 0), QPoint(chartWidget->width(), chartWidget->height())));
> QByteArray* ba;
> QBuffer buffer( ba );
> buffer.open( QIODevice::WriteOnly );
> pm.save( &buffer, "PNG" ); // writes pixmap into ba in PNG format
>
> m_html += QString("<table width=\"100%\" cellspacing=\"0\"
> cellpadding=\"2\" class=\"summarytable\" >");
> m_html += QString("<tr>");
> //m_html += QString("<td><center><IMG SRC=\"data:image/png;base64,%1\"
> ALT=\"Networth\"></center></td>").arg(ba->toBase64().data());
> m_html += QString("</tr>");
> m_html += QString("</table></div></div>");
>
> As you can, the relevant line is commented out for the moment, because the
> conversion from the buffer which has the QPixmax stored, to base64 to then
> show it on the home page, causes a crash.

Straight from the Qt docs:

     QPixmap pixmap;
     QByteArray bytes;
     QBuffer buffer(&bytes);
     buffer.open(QIODevice::WriteOnly);
     pixmap.save(&buffer, "PNG"); // writes pixmap into bytes in PNG format

which is identical to Qt3 (so we have another bug to fix here in the KDE3 
version - I'll take care of it).

-- 

Regards

Thomas Baumgart

GPG-FP: E55E D592 F45F 116B 8429   4F99 9C59 DB40 B75D D3BA
-------------------------------------------------------------
Laziness led to the invention of the most useful tools.
-------------------------------------------------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 224 bytes
Desc: This is a digitally signed message part.
Url : http://mail.kde.org/pipermail/kmymoney-devel/attachments/20091023/d27eb65e/attachment.sig 


More information about the KMyMoney-devel mailing list