PDA

View Full Version : Relative paths in Qt



drmath
25th June 2010, 14:36
I want to link a custom widget plugin (called for example MyWidget.dll) to a Qt project (developed on Win Xp), accessing to the linked file without moving it from its release directory (whatever). Of course LIBS += C:\Path_to_dll\MyWidget.dll meets the purpose, but I have to expressly use the relative path. How can I do that?

locke
25th June 2010, 16:41
Hi,

I think that you need the relative path because in the future installation, you dont know where the user will install the app, right?

I suggest to use the environmental variable that your app will install in the registry. An the catch it for your path as



LIBS += $$(MY_ENV_VAR)/my/path/to/MyDLL.dll


Hope it helps

drmath
30th June 2010, 16:50
Thanks for the reply, but what I'm looking for is the Qt equivalent of C++ directive

#import "..\..\MyDLL_Directory\MyDLL.dll"

In such a way, if I move (at design time) the project pointing to MyDLL on another PC with the same tree structure but possibly different directories names, the linking works fine without modifying LIBS source code in .pro file. Also, avoiding to copy MyDLL file from its release folder into project directory, assure the project will point always to latest MyDLL version. In other words, there exists in Qt a syntax equivalent to C++ pattern "..\..\..\.." ?