Qt-interest Archive, July 2007
qpixmap and html
Message 1 in thread
May be it's very trivial but I cannot figure out at the moment how I can
manage it.
If I want to embed a QPixmap from the Qt resource system, I just use "<image
src=:/mypix.png>". Now I need to put some pixmaps or svgs that were created
at runtime into the html code. The html code is shown later in a "print
preview widget". My first idea was something like this
QPixmap pix;
//create pixmap
htmlString += "<img src=pix>";
This doesn't work, of course. Do I need to convert my pixmap to char? Or is
there a simpler way to do this?
Alexander Semke.
--
[ signature omitted ]
Message 2 in thread
On Jul 28, 2007, at 11:51 AM, Alexander Semke wrote:
> May be it's very trivial but I cannot figure out at the moment how
> I can
> manage it.
> If I want to embed a QPixmap from the Qt resource system, I just
> use "<image
> src=:/mypix.png>". Now I need to put some pixmaps or svgs that were
> created
> at runtime into the html code. The html code is shown later in a
> "print
> preview widget". My first idea was something like this
>
> QPixmap pix;
> //create pixmap
> htmlString += "<img src=pix>";
>
> This doesn't work, of course. Do I need to convert my pixmap to
> char? Or is
> there a simpler way to do this?
I'm not sure is it the best way to solve your problem, but propably
you have to save your image to disk with QImage::save method, and
then put proper path in <img src=""/>
--
[ signature omitted ]
Message 3 in thread
Alexander Semke wrote:
> May be it's very trivial but I cannot figure out at the moment how I can
> manage it.
> If I want to embed a QPixmap from the Qt resource system, I just use "<image
> src=:/mypix.png>". Now I need to put some pixmaps or svgs that were created
> at runtime into the html code. The html code is shown later in a "print
> preview widget". My first idea was something like this
>
> QPixmap pix;
> //create pixmap
> htmlString += "<img src=pix>";
>
> This doesn't work, of course. Do I need to convert my pixmap to char? Or is
> there a simpler way to do this?
If you are using a QTextBrowser or QTextEdit, you can use
http://doc.trolltech.com/4.3/qtextdocument.html#addResource. If you are
using a QLabel, I don't think there is a mechanism without having to
save the pixmap somewhere on the disk. I remember seeing a task
requesting this functionality but I cannot find it now.
Girish
--
[ signature omitted ]
Message 4 in thread
Girish Ramakrishnan wrote:
> If you are using a QTextBrowser or QTextEdit, you can use
> http://doc.trolltech.com/4.3/qtextdocument.html#addResource. If you are
> using a QLabel, I don't think there is a mechanism without having to
> save the pixmap somewhere on the disk.
Well, that's not the most elegant way to solve this problem but it works:-)
Thank you and Kamil.
Alexander Semke
--
[ signature omitted ]
Message 5 in thread
Girish Ramakrishnan wrote:
> If you are using a QTextBrowser or QTextEdit, you can use
> http://doc.trolltech.com/4.3/qtextdocument.html#addResource. If you are
> using a QLabel, I don't think there is a mechanism without having to
> save the pixmap somewhere on the disk. I remember seeing a task
> requesting this functionality but I cannot find it now.
You would just use QPixmap::loadFromData() with QLabel if you had access to
the raw image data. There's no need to overcomplicate things! ;-)
David
--
[ signature omitted ]
Message 6 in thread
David Boddie wrote:
> Girish Ramakrishnan wrote:
>
>> If you are using a QTextBrowser or QTextEdit, you can use
>> http://doc.trolltech.com/4.3/qtextdocument.html#addResource. If you are
>> using a QLabel, I don't think there is a mechanism without having to
>> save the pixmap somewhere on the disk. I remember seeing a task
>> requesting this functionality but I cannot find it now.
>
> You would just use QPixmap::loadFromData() with QLabel if you had access to
> the raw image data. There's no need to overcomplicate things! ;-)
Of course :) This is the case if the user just wants to show a pixmap in
a QLabel. I was referring to the case where the user wants to display a
html that has a reference to the pixmap in a QLabel.
Girish
--
[ signature omitted ]