JPEG Image isn't displayed!?
Hi there!
This my first time on this forum.
I'm creating an application for an exam and I need to display a JPEG image in the application.
Here is the code:
Code:
#include <QApplication>
#include <QImageReader>
#include <QWidget>
{
public:
};
MyWidget
::MyWidget(QWidget *parent
) {
}
int main(int argc, char *argv[])
{
MyWidget widget;
widget.show();
return app.exec();
}
I'm using QT 4.2.3 Open Source with Visual Studio 2005.
When I run the application I see a blank dialog with the same image size. Where is the mistake? Can you help me?
PS. Sorry for bad english but I am Italian
Re: JPEG Image isn't displayed!?
Code:
#include <QApplication>
#include <QWidget>
#include <QPixmap>
#include <QPainter>
#include <QPaintEvent>
{
public:
protected:
};
MyWidget
::MyWidget(QWidget *parent
)
{
setFixedSize( mPixmap.size() );
}
{
if( !mPixmap.isNull() )
{
p.drawPixmap( 0, 0, mPixmap );
}
}
int main(int argc, char *argv[])
{
MyWidget widget;
widget.show();
return app.exec();
}
Re: JPEG Image isn't displayed!?
Try using QLabel::setPixmap().
Re: JPEG Image isn't displayed!?
Maybe you don't have JPEG support turned on? What does
output? This requires reconfiguring and rebuilding Qt libs, see configure -help for more info.
Re: JPEG Image isn't displayed!?
Make sure the image is in the same folder as the executable. Otherwise, give the complete path when you create the QPixmap.
Re: JPEG Image isn't displayed!?
[ot]
how are you using Qt4 OpenSource + Visual Studio?
Re: JPEG Image isn't displayed!?
The hardest part is to get Qt compiled.
To start a project, you just need to set the appropriate include paths and library paths in the project properties, just as Qt VS Integration does.
Regards
Re: JPEG Image isn't displayed!?
To start a project you just need to call "qmake -tp vc" :)
Re: JPEG Image isn't displayed!?
Quote:
To start a project you just need to call "qmake -tp vc"
Or that... :)
Re: JPEG Image isn't displayed!?
Quote:
Originally Posted by
marcel
Code:
#include <QApplication>
#include <QWidget>
#include <QPixmap>
#include <QPainter>
#include <QPaintEvent>
{
public:
protected:
};
MyWidget
::MyWidget(QWidget *parent
)
{
setFixedSize( mPixmap.size() );
}
{
if( !mPixmap.isNull() )
{
p.drawPixmap( 0, 0, mPixmap );
}
}
int main(int argc, char *argv[])
{
MyWidget widget;
widget.show();
return app.exec();
}
I managed to make it work using this code thx:D ! (Actually I had to modify line 29).
@jpn
Where do I have to place that instruction in order to show something??
FOR ALL:
Can someone explain me why it doesn't work with the QImageReader?