[Interest] QGraphicsWidget and custom QToolTip
Petric Frank
pfrank at gmx.de
Wed Jan 22 20:45:16 CET 2014
Hello,
i've got it to use it with a QLabel. For the records (Qt 5.2.0) here is
example code (ui->label is of type QPixmap* ):
--------------------- cut -----------------------
QPixmap pixmap;
... some drawing tasks ...
QByteArray byteArray;
QBuffer buffer(&byteArray);
pixmap.save(&buffer, "PNG");
QString url = QString("<img src=\"data:image/png;base64,") +
byteArray.toBase64() + "\"/>";
QString text = "<html><h1>Test</h1>here is an image: ";
text += url;
text += "</html>";
ui->label->setTextFormat(Qt::RichText);
ui->label->setText(text);
--------------------- cut -----------------------
Hope that helps someone.
regards
Petric
P.S.: Sorry for top-posting
Am Mittwoch, 22. Januar 2014, 18:40:43 schrieb Petric Frank:
> Hello Oliver,
>
> Am Mittwoch, 22. Januar 2014, 08:21:11 schrieb Till Oliver Knoll:
> > Am 21.01.2014 um 20:25 schrieb Petric Frank <pfrank at gmx.de>:
> > > ...QGraphicsWigdet. Only texts (w/ reduced HTML) can be
> > > passed to the setTooltip method.
>
> The class i meant QGraphicsItem, not QGraphicsWidget - my mistake.
>
> > Haven't tried it, but wouldn't it be possible to define an <img> tag then
> > which references an /embedded/ QPixmap (which would have to be
> > dynamically created, off course - somehow).
>
> Exactly what may solve my problem. How this <img> tag must be crafted. And
> how the c(++) code must look like to be referred ?
> So having in the code an QPixmap instance like
> QPixmap pixmap;
>
> filled with the drawing i wnt to have.
> How to refer it ?
>
> > > ...
> > > Or is it - in this case - allowed to include the private header ?
> >
> > It is always "allowed" to include whatever you want (at least in the Qt
> > world anyway - some other companies have a different view on that topic
> > when it comes to "App Store Rules" ;)), as long as you remember what
> > "private" implies: "You're on your own!"
>
> Thats the reason i want to avoid it.
>
> > So the only one who might "punish" you is your compiler once those
> > private headers change...
>
> exactly.
>
> > That said, if you have a valid use case and the private API call does
> > work, you could make a "feature request" - or even better: provide your
> > own Qt changes to the project for review :)
>
> If there is no other way i may go on this track.
>
> The use case may be a genealogy tree and display a picture of the member
> (together with additional info) when hovering a mouse over it. The picture
> is placed in a database, so not referrable by ordinary <img> tags.
>
> regards
> Petric
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
More information about the Interest
mailing list