PDA

View Full Version : How to get the installation directory of Qt 4?



kartwall
17th September 2010, 08:54
Hi, I wanna know how to get the installation directory of Qt4?
Which function can do this? Thanks a lot.

^NyAw^
17th September 2010, 09:25
Hi,
It depends on your OS. On Windows you can check the system variable "QTDIR".


char* qtdir = getenv("QTDIR");


I don't know if Linux have "getenv" function but there will be a similar one.

kartwall
17th September 2010, 09:31
Hi, NyAw. Thank you for your response.
But seems the method you mentioned doesn't work.
I'm using Ubuntu 9.10 here and I tried the command:
echo $QTDIR

It's empty. No environment variable named QTDIR defined.

^NyAw^
17th September 2010, 09:35
Hi,

Ok, i doesn't exists but you can create it. Use your favorite search engine to find hot to define environment variables on Linux

kartwall
17th September 2010, 10:20
Hmm... NyAw, I think you misunderstand my meaning. Suppose we'll install our Qt program into a computer. How can I suppose there is a QTDIR environment variable is available?
Right now what I want is, in a computer which installed Qt 4, to get the installation directory of Qt. So how can I set this QTDIR myself? I don't know where the Qt is.

^NyAw^
17th September 2010, 10:48
Hi,

The installation on Windows will create the variable for you. On Linux I don't know if it is created. I'm telling you that you can create the variable when you install the application on another system. It's so easy.


Hmm... NyAw, I think you misunderstand my meaning

I understand what you want. Maybe you don't understood what I told you

PD: Check Qt on Linux installation guide that will tell you if the variable is created or you have to define it.
But, I think that this is not a Qt programming related question.

kartwall
20th September 2010, 03:38
Thank you, NyAw. I got what you mean. Just as you said here:



I'm telling you that you can create the variable when you install the application on another system. It's so easy.
.

I can create the env variable to save the Qt's installation directory in my installation program, but the key point is: how to find out where the Qt installed?

My original meaning is, whether Qt provides a class/function to make it possible to check out the Qt's installation directory directly. If the answer is no, yes, this is not a Qt programming related problem.

wysota
20th September 2010, 09:00
See QLibraryInfo::location().

kartwall
20th September 2010, 09:19
Hi, wysota:
Thank you very much. It works! :)