Dear Everyone!
How a way we can insert image into a QTextBox.
regards!
Dear Everyone!
How a way we can insert image into a QTextBox.
regards!
Anurag Shukla
A man who never makes mistake is the man who never does anything! Theodre Rosvelt!
I suppose you mean QTextEdit? Which version of Qt are we talking about? Qt 3 and Qt 4 are pretty much different so could you please mark your questions related to either one.
J-P Nurmi
I use Qt3 for this.
Anurag Shukla
A man who never makes mistake is the man who never does anything! Theodre Rosvelt!
From QTextEdit docs:
What did you try so far?QTextEdit can display images (using QMimeSourceFactory), lists and tables.
...
The images identified by image tags are displayed if they can be interpreted using the text edit's QMimeSourceFactory; see setMimeSourceFactory().
J-P Nurmi
Don't you think it would be appropriate to show some effort on your own?
Last edited by jpn; 15th September 2007 at 09:32. Reason: reformatted to look better
J-P Nurmi
Dear Sir i am using following code. it run but doesn't show image into QTextEdit.
#include <qpixmap.h>
#include <qmime.h>
void dlgImage:bShowImage_clicked()
{
QPixmap pImg("s.png",0,1);
QMimeSourceFactory *factory=new QMimeSourceFactory();
factory->setPixmap("/root/desktop/img/s.png",pImg); /* I cann't understand the first argument means*/
txtImage->setMimeSourceFactory(factory);
}
Anurag Shukla
A man who never makes mistake is the man who never does anything! Theodre Rosvelt!
This is explained in the detailed description of QMimeSourceFactory. It should equal the source-attribute of image-element:
Qt Code:
QMimeSourceFactory::defaultFactory()->setPixmap("anything_you_want", pImg); textEdit->setHtml("<img source=\"anything_you_want\">");To copy to clipboard, switch view to plain text mode
Edit: Oh, and textEdit->setHtml() should be textEdit->setText() since it's Qt 3![]()
Last edited by jpn; 15th September 2007 at 14:32. Reason: updated contents
J-P Nurmi
Bookmarks