[Qt-interest] Images in tooltips
Yves Bailly
yves.bailly at sescoi.fr
Wed Dec 22 15:40:29 CET 2010
newsletters at philippberger.de a écrit :
>> I need to display images in tooltips. But the images can't be stored as
>> internal resources or on the local disk - they're dynamically computed
>> and stored as QImage instances.
> [...]
>
> Easy enough using some HTML hacks :)
> I wrote a small function that will convert your QImage to a QString you
> can embed into a tooltip:
>
> QString getImageAsText(const QImage AImage) {
> QByteArray ba;
> QBuffer buffer(&ba);
> buffer.open(QIODevice::WriteOnly);
> AImage.save(&buffer, "PNG");
> return QString("<img
> src=\"data:image/png;base64,%1\">").arg(QString(buffer.data().toBase64()));
> }
Philipp, that's simply brilliant, works great :-)
Thanks a lot for this nice trick.
--
/- Yves Bailly - Software developper -\
\- Sescoi R&D - http://www.sescoi.fr -/
"The possible is done. The impossible is being done. For miracles,
thanks to allow a little delay."
More information about the Qt-interest-old
mailing list