PDA

View Full Version : Problem in running QT Application



beginQT
5th October 2011, 08:59
Hello,

As I mentioned earlier I am using QT Eclipse for my project. I have done some texture mapping in my code.
After that compilation has gone well but, when I try to run the Application, one Error popup appears and says .exe encountered a problem and needs to be closed.

When I go for details I can see something like this.

AppName: Example.exe AppVer: 0.0.0.0 ModName: qtguid4.dll
ModVer: 4.6.4.0 Offset: 006fb1e6

I dont understand whether its problem with my code or something else, because when I remove Texture mapping part of the code it works fine. For texture mapping I am just using QT's bindtexture method and standard Opengl commands for drawing.

I need some help Please...

Thanks in Advance!

mentalmushroom
5th October 2011, 11:17
well, difficult to guess what that could be, but perhaps something related to DEP if you work on windows XP sp2 or newer. I had this problems with OpenGL and solved it by marking my app incompatible with DEP.

beginQT
5th October 2011, 12:00
What is this DEP? could you please eloberate? And please let me know how to set that DEP.
I am using Windows XP with SP3.

Thanks in Advance!

mentalmushroom
5th October 2011, 15:19
http://en.wikipedia.org/wiki/Data_Execution_Prevention

If you are using visual studio, open project properties, go to linker > advanced, in the field "data execution prevention (DEP)" choose "Image is not compatible with DEP". It was just my guess, it is very likely your problem is something else. Try step-by-step debugging and find the exact line where the app crashes.

beginQT
5th October 2011, 16:41
This is because some wrong code in resizeGL() method. Its solved now!

Other problem is I am not able to load Image from the specified path using QImage.load method.

Looks like problem lies in Image loading. Code written for Image is not picking the Image from the Path specified.
imgLoaded = img.load(_sPath); always returns false!
Path given is : ./PICS/Car_New1.png, Passed as a QString to PICData function.

Is there a other way to give Path info? I have a project inside Eclipse workspace and inside that i have folder called "PICS", I am just giving that path to it.

Any Idea?

Thanks!

ChrisW67
6th October 2011, 00:00
You used a relative path to the image... what is your current directory?

beginQT
6th October 2011, 07:02
HI,

My current directory is Eclipse Workspace.
the path will besome like this: c:\Eclipse Workspace\project\debug\pics\*.png;

This is the actual path, Is this is what your question was?

Thanks!

ChrisW67
6th October 2011, 07:25
When a program fails to open a file that does exist, and you have specified a relative path, the odds are very good that the current working directory is not what you think it is (see QDir::currentPath()).

You can obtain the location of the program executable using QCoreApplication::applicationDirPath() and build a path to the file that way.
You can embed images in the executable using the resource system.

It's also possible the image cannot load because a suitable image format plugin is not available (should not be the case with PNG).

beginQT
6th October 2011, 08:44
Now, I have taken the current dir path..still same no results yet. This is what i am doing:

filename = QDir::currentPath();
imgLoaded = img.load(filename +"/PICS/Car_New1.PNG" );

if(true == imgLoaded)
{
_sPic.iId = this->bindTexture(img, GL_TEXTURE_2D, GL_RGB);
_sPic.iHeight = img.height();
_sPic.iWidth = img.width();
}

And, I have added this png in QRC file too its been embeded in Executables also but i dont know how to use this to map to our current context.

Thanks!

ChrisW67
6th October 2011, 09:08
You seem to have missed the point. What is the value of currentPath()? Is it where you think it is? The current directory can be anywhere on the system and has nothing to do with the location of the program executable.

The Qt Resource System

beginQT
6th October 2011, 10:45
I have seen some QT open gl Texture examples and I am also doing the same thing almost. But i dont understand why it doesn't work for me -:( may be I am doing some basic mistake which I am not able to uncover.

How would I solve it? I dont have any clue about the problem!
Would it going to help me if I place whole code?

Thanks!

ChrisW67
6th October 2011, 22:51
I have already told you the most likely thing that is going wrong.

Qt can only open the file if the file is where you tell Qt it is. If you are using a relative path then the file will be looked for relative to the current working directory of the running process, which can move around as the program runs. This is not generally the same as the directory containing the program executable. Unless you know the actual current working directory then you cannot know whether you are trying to open the file you think you are.

You can use the Qt resource system to embed the image into your executable (if that meets your needs) so that it can always be found. I have already provided a linking detailing how this is used.