PDA

View Full Version : loading an image onto any form's widget



sudheer
29th November 2007, 06:30
hi friends, i can able to load a text file onto the form's "textEdit" widget but i am not able to load an image since in a Designer there are only few display widget(like QGraphicsView,LCD) so how can i load an image????

jpn
29th November 2007, 08:19
With QTextEdit you will have to use QTextDocument::addResource():

textEdit->document()->addResource(QTextDocument::ImageResource, QUrl("url-used-in-html"), QImage("image.png"));
Just notice that QTextBrowser is capable of loading resources from local files out of the box.

sudheer
29th November 2007, 13:07
not only with the QTextEdit, but there are other classes like QImage,QImageReader how can i use these classes to display the image. I have written something like this

"QString filename = QFileDialog::getOpenFileName(this);"

with this file "filename" can i display the image using QImage class (since it has fun'
QImage::QImage ( const QString & fileName, const char * format = 0 ) )

any suggess' plz welcome

jacek
29th November 2007, 13:48
If you just want to display an image, you can use QLabel. Also use QPixmap instead of QImage.

sudheer
1st December 2007, 05:55
thank q , now i can able to display system image files(.jpg,.png,gif,.bmp format ) using
both classes QLabel(on form's label widget) and QPixmap