PDA

View Full Version : insert image at the bottom of QTextEdit



Cortex
21st October 2009, 21:35
Hello,

I need to insert an image as a footer in QTextEdit.

How can I reach the end of the QTextEdit and put the image.

How can I stick it in that place.

Thanks a lot

kwisp
22nd October 2009, 07:57
may be
http://www.wysota.eu.org/wwwidgets/
helps you.
see QwwButtonLineEdit
and
QwwClearLineEdit

Cortex
22nd October 2009, 13:00
Thanks Kwisp,
That seems interesting.
Unfortunately, the feature am looking for is not likely to be implemented by wwWidgets ..
Any other suggestions ? ..

Lykurg
22nd October 2009, 13:58
Hi,

first we - at least I - prefer normal font size. Second I only see a possibility for your footer if you subclass QTextEdit and watch the modification of the QTextDocument. There you must ensure that the footer is the last text. If that isn't the case, change the document.

Cortex
22nd October 2009, 22:46
Sorry for the font size.

Lykurg, I didn't see your point, my footer is not a text it's an image.

Well, I ended up with:
- Subclassing textEdit
- Reimplementing paintEvent()
- inserting the image as Pixmap using painter.drawPixmap()

wysota
23rd October 2009, 00:15
Is the footer part of the document or part of the widget? If the latter, then indeed looking at wwWidgets' source code might be helpful.

Cortex
23rd October 2009, 13:37
It's rather the former .. I need to print it with the document later.

wysota
23rd October 2009, 14:12
So what is the problem? Just insert the footer into the document and don't allow the user to edit it.

Cortex
23rd October 2009, 14:29
How to do that? I mean inserting the footer in the document.

wysota
23rd October 2009, 14:45
QTextCursor

Cortex
24th October 2009, 13:46
How to make the cursor go down to the bottom of the document and insert the image, stick it there so it won't move if the user edit the document ?
That was exactly my question from the beginning.

As I said earlier, the best solution I found is to draw it with paintEvent().

wysota
24th October 2009, 15:15
Just go through QTextDocument and QTextCursor API. QTextCursor::insertImage is the most likely thing to use to insert an image, don't you think?

Cortex
24th October 2009, 16:22
I've seen all these classes, before I post here.
It's not about simply insert an image into a QTextDocument.
Anyway I managed to solve it now.
I do thank you.