PDA

View Full Version : [problem]displaying image with Pixmap



crazy_inf
3rd July 2008, 08:49
Hiya world ....
I have just started to do my own Qt projects....and I crossed a lot of problems realy !!
Okey , without be long..i give you my source code..

#include "visionneur.h"

Visionneur::Visionneur(): QWidget()
{

m_ouvrir=new QPushButton("Ouvir une image",this);
QObject::connect(m_ouvrir,SIGNAL(clicked()),this,S LOT(ouvrir()));
m_contenu=new QLabel(this);
m_contenu->setFrameShape(QFrame::Panel);
m_contenu->setPixmap(QPixmap("image.png"));

}
void Visionneur::ouvrir()
{
QString image = QFileDialog::getOpenFileName(this, "Ouvrir un fichier", QString(), "Images (*.png *.gif *.jpg *.jpeg)");

}
Visionneur::~Visionneur()
{
}
Problem: the image doesnt apear on my window :confused:
I'd like some help to resolve that probleme , I'm using Dev-c++:o

caduel
3rd July 2008, 09:49
possible issues:
* make sure image.png is in the directory you call your program from
* set a layout on your widget
* check that your Qt build supports .png
try

QLabel *l = new QLabel;
l->setPixmap(QPixmap("image.png"));
l->show();
Does this show the image?

HTH