PDA

View Full Version : How to include qrc resource file in Visual Studio 2005?



jambrek
6th February 2008, 14:29
Hello everyone,

I used Eclipse with Qt, and I have not any problems about using qrc resource file. Now I am using Qt with Visual Studio 2005, and I don't know how to implement my resource file. Resource file is good, it works in eclipse. Visual Studio use *.rc files for resources, and can not recognize *.qrc. Is there any other way to display picture in Qt (not to use resource files)?

Thanks a lot!

jambrek
6th February 2008, 16:00
I forgot to mention that I'm using Qt open source version (4.3.3) and I haven't in Visual Studio make new Qt project and nothing related to Qt, so I can't simply add a qrc resource file. My Qt application work fine.

Thanks

jpn
6th February 2008, 16:42
Well, the open source edition has no Visual Studio integration so you will have to handle the resource file as an ordinary XML file. Luckily the syntax of Qt resource file (http://doc.trolltech.com/latest/resources.html) is very simple.

bender86
6th February 2008, 17:20
Instead of editing manually, you can also edit qrc files from designer.

jambrek
6th February 2008, 18:01
Hi, thanks for yours reply,

I already have proper qrc file. How I can import xml file? Do I have to simply change extension of my *.qrc file into *.xml. When I go to Add resource there is only html format. Qt designer accepts only *.qrc files.

Thanks!

jpn
6th February 2008, 18:15
Sorry for being unclear. What I meant was that you can edit it like any other XML file. But indeed, Qt Designer is much better choice for handling .qrc files. ;)

jambrek
6th February 2008, 18:26
I know how to make *.qrc files, I don't know how to tell Visual Studio that *.qrc is a resource file. Visual Studio don't know what is qrc extension, and I can't implement qrc file into my project. I used this project on Eclipse and this work just fine, pictures are showed up, but I had to use Visual Studio, and now my pictures wouldn't shows up. Resource file is same in both platforms (Visual and Eclipse).

jpn
6th February 2008, 18:54
Do you have the resource file in your .pro file and did you generate the Visual Studio project with qmake?

jambrek
7th February 2008, 12:38
I don't have .pro file. I had it in Eclipse, but no in Visual Studio. I have console application project in Visual Studio. I set up my project like this (http://www.qtcentre.org/forum/f-installation-5/t-set-up-the-qt432-with-visual-studio-2005-10047.html). That is a problem, because I don't have a .pro file.

jpn
7th February 2008, 13:02
Then perhaps you should start using one? Do you ever plan to build your project in any other environment than Visual Studio? Do you ever plan to let anyone else build that project? What if he doesn't have Visual Studio but is using GCC/MinGW/Eclipse/XCode/whatever he prefers?

The great advantage with qmake .pro file is that it's cross-platform and independent of building environment. qmake supports lots of compilers on lots of platforms. Additionally, qmake is even able to generate a Visual Studio project file (.vcproj) for you. On the other hand, a Visual Studio project file is tied to Visual Studio. There's not much you can do with a Visual Studio project file on Linux with GCC.

jambrek
7th February 2008, 16:55
Reason why I'm using Visual Studio is that I couldn't include win32 libraries in .pro file.

bender86
7th February 2008, 17:18
Reason why I'm using Visual Studio is that I couldn't include win32 libraries in .pro file.

Yes, you can. You should add something like this in your .pro file.

TEMPLATE = app
QT += network

...

LIBS += NetApi32.lib Advapi32.lib

...

jambrek
8th February 2008, 12:28
I added this:

LIBS += -LD:/Darko/projects/PCapp -lFTCJTAG -lFTD2XX
But this recognize only *.a libraries. I found this way of loading libraries on the internet. -L is for folder, and -l is for file.

jpn
8th February 2008, 12:33
You should use docs as number one reference: qmake Variable Reference - LIBS (http://doc.trolltech.com/latest/qmake-variable-reference.html#libs)

jambrek
8th February 2008, 12:53
Thanks a lot. Now I have to set up my environment for eclipse and mingw again.

jpn
8th February 2008, 12:58
Thanks a lot. Now I have to set up my environment for eclipse and mingw again.
Perhaps if you stated the problem we were able to help you. bender86 already gave you the preferred way to link libraries with MSVC. Docs state the same. So what's the problem?

jambrek
8th February 2008, 14:21
Now I saw that my post sounds little ironic, but I didn't meant like that. I truly want to thanks you.

jambrek
8th February 2008, 17:56
I have a problem. I set up qt for eclipse+mingw, and use code from visual studio, and load libraries in this way. There is no compiler or linker errors, but when I try to start my program nothing will shows up. Program is automatically terminated. When I load old project (without libs) it's works just fine (in eclipse+mingw+qt). Any ideas?
Thanks

jambrek
8th February 2008, 18:26
My mistake, i had to copy some .dlls. Now it's works.