I want to know how to display an image simply on a window i.e. how to just open a picture stored in the images folder in Qt? Plz give me the code to be added into the main() program.
I want to know how to display an image simply on a window i.e. how to just open a picture stored in the images folder in Qt? Plz give me the code to be added into the main() program.
Last edited by wysota; 27th July 2010 at 13:28.
QLabel label;
label.setPixmap(QPixmap("imagename"));
so I'll have to do QLabel::setPicture ( ":/images/transparent.png")???
There's one more problem. even when I run a basic code with the .qrc file and a folder "images" in the "new" folder in "bin", it shows "fatal error: can't open 'debug/new.exe' "........... I am showing the code below:
//new.cpp
#include <QApplication>
int main(int argc,char *argv[])
{
QApplication app(argc,argv);
return app.exec();
}
//new.qrc
<RCC>
<qresource>
<file>images/transparent.png</file>
</qresource>
</RCC>
//The contents of the new.pro file are:
TEMPLATE = app
TARGET =
DEPENDPATH += . tmp\rcc\debug_shared
INCLUDEPATH += .
# Input
SOURCES += new.cpp
RESOURCES += new.qrc
What is the error in this???
Thanks a lot,but ,there's one more problem. even when I run a basic code with the .qrc file and a folder "images" in the "new" folder in "bin", it shows "fatal error: can't open 'debug/new.exe' "........... I am showing the code below:
//new.cpp
#include <QApplication>
int main(int argc,char *argv[])
{
QApplication app(argc,argv);
return app.exec();
}
//new.qrc
<RCC>
<qresource>
<file>images/transparent.png</file>
</qresource>
</RCC>
//The contents of the new.pro file are:
TEMPLATE = app
TARGET =
DEPENDPATH += . tmp\rcc\debug_shared
INCLUDEPATH += .
# Input
SOURCES += new.cpp
RESOURCES += new.qrc
What is the error in this???
First thing: Does the directory actually exist?
Whats in the debug folder at the moment?
It is all clear........ "MasterOfZen" was right.......thanx a lot 2 u guys
Bookmarks