PDA

View Full Version : plz help



qt_user
27th July 2010, 10:48
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.

tbscope
27th July 2010, 10:56
http://doc.qt.nokia.com/4.6/qlabel.html#setPicture

GreenScape
27th July 2010, 11:53
QLabel label;
label.setPixmap(QPixmap("imagename"));

qt_user
27th July 2010, 12:00
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???

qt_user
27th July 2010, 13:08
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???

squidge
27th July 2010, 13:24
First thing: Does the directory actually exist?

wysota
27th July 2010, 13:26
it shows "fatal error: can't open 'debug/new.exe'
You probably have another instance of the application running and the compiler can't overwrite the executable.

qt_user
27th July 2010, 18:13
You probably have another instance of the application running and the compiler can't overwrite the executable.

I also thought on the same lines as you but......I could not find the existence of another instance in the processes in the task manager. How should I close that instance(other than restarting the computer-which I have not tried yet)

qt_user
27th July 2010, 18:15
First thing: Does the directory actually exist?

ya the directory exists...........(did I not get what u intended to say???)

squidge
27th July 2010, 18:42
Whats in the debug folder at the moment?

qt_user
28th July 2010, 05:48
It is all clear........ "MasterOfZen" was right.......thanx a lot 2 u guys