tags:

views:

83

answers:

1

All,

I must have a fundamental neuron missing, but I cannot get a simple program to load a PNG file and display it in a window. I'm not sure if it is a QPixmap, a QPicture, or what. All of the samples in the QTCreator are a bit more than I need right now. Baby steps...

I can get the window to display, and the program doesn't barf when I try to load the PNG, but it never gets displayed.

If someone would post a simple program to load a PNG from a file and display it, it would greatly appreciated. (I know, asking a lot, but...).

Thanks!

:bp:

+1  A: 

Hi, this example is minimal: http://doc.trolltech.com/4.6/widgets-imageviewer.html

You will want to have a look at the function ImageViewer::open():

  1. Build a QImage object from a filename;
  2. Convert your QImage to a QPixmap with QPixmap::fromImage();
  3. Put your QPixmap in a QLabel with QLabel::setPixmap().

The QImage object will automatically chose an appropriate reader according to the format of the image it detects in step 1.

Julien L.
Thanks! I'll start digging! Much Appreciated!
Billy Pilgrim