PDA

View Full Version : QWT examples in Visual Studio 2005



Roelof
12th August 2009, 13:30
Good day.

If anybody has succesfully implemented the QWT examples in visual studio, i would greatly appreciate it if you can assist me on how to add the example files in Visual studio.

I have installed Qt4.5 with the visual studio plug-in and Qwt5.2 succesfully. I am now trying to build a example in visual studio.

Any help would greatly be appreciated

Kind Regards

emrares
13th August 2009, 06:31
i managed to compile some of the examples in VS 2005.

1. Create a new console app.
2. copy the cpp and h files to your project dir.
3. add the cpp and h files to your VC project
4. go to project propreties -> linker -> input and add this line QtGui4.lib QtCore4.lib qwt5.lib
5. if any class has Q_OBJECT defined make sure to make the MOC file and add it to you project

i think that's all. good luck

Roelof
13th August 2009, 11:04
Hi.
Thanx again emrares.

Do you have any idea how to do this while creating a Makefile project in Visual Studio? Im doing a project that requires QT buttons to activate QWT plots. Thus the reason for doing Makefile projects.

I don't know where to add the *.lib files and get a lot of linking errors. If anybody else knows as well I would appreciate it

Thanx for the help

emrares
13th August 2009, 13:38
this should help you to get rid of the linking errors. you don't need QtSvg4.lib


Do you have any idea how to do this while creating a Makefile project in Visual Studio

i have no ideea :confused:

Roelof
13th August 2009, 14:58
Thanx again.

I added the libraries where you told me. However, in win32 console project, Visual studio can't find the QT headers anymore. It still works fine in my QT applications, but not with the win32 console application.

I started with the simple plot example of QWT and added the "simple.c" file in visual studio.
If you can think what my problem is, please let me know. Else I will keep on searching.

The last thing I want to ask:
If I use an example that uses QOBJECT in the claas. How do I create the MOC file and where do I add it in my project? (Header,Resource, Source?)

Thanx emrares. You have already helped me very much!

emrares
13th August 2009, 15:46
I will post the answer, and some screenshots tomorow morning when i get to work. You need to make some settings to VS that I cannot remember right now.

just wanted to let you know that i saw your post, and i will help you :)

emrares
14th August 2009, 08:16
Visual studio can't find the QT headers anymore

go to Visual Studio Options-> Projects and Solutions -> VC++ Directories

you should see there "Show Directories for" combo-box. Select from the combo box Include files and in the list box add the path of your Qwt installation directory ( the directory that has the header files). for example "D:\ProgUtil\qwt-5.2.0\src"

you should add there the path to the Qt directory too. (take a look at the files attached to this post)

Next select from the combo box "Library files" and add to the list the path for the lib directory.


How do I create the MOC file and where do I add it in my project

If you take a look in the Qt directory (c:\Qt\2009.03\qt\bin\) you should see there a file moc.exe That's the file that will generate the moc files.

To use it, go to your VC project directory and create a new directory "moc_files" in the directory create a new file (with notepad) and name it "MakeMOC.bat" in the file type this

@echo off

C:\Qt\2009.03\qt\bin\moc -o moc_MYFILE.cpp ..\MYFILE.h

you will replace "C:\Qt\2009.03\qt\bin" with the path of your Qt installation directory and MYFILE with your filename.

save the MakeMOC.bat file and when you will execute it it will generate a moc_file. Remember only generate moc files for the header files that have Q_OBJECT defined.

How do you attach the moc files to your VC++ project?

open your project, right click your project name Add -> New Filter give a name to your filter for example moc_files and next right click the moc_files filter Add -> Existing Item and add your moc_files to your project.

That's all. Remember that when you add a new signal or slot to a header file you should recreate your moc file. Go to the moc_files directory and execute MakeMOC.

Roelof
14th August 2009, 10:10
Thanx Emrares!

Me and a lot of people working above me... is very thankfull for your help. I did it all and it works good!

I found another way of executing the QWT example files in visual studio. This approach is hard if you want to really alter the example, but gives a good starting point for qwt in visual studio for those interested.

1. Open command line prompt. Set up the visual studio environment. This can be done by running "vcvars32.bat" located in my case in "Program files\Microsoft Visual Studio 8\VC\bin. Change directory to this path and type vcvars32.bat. This sets up the visual studio environment

2. Change directory to the qwt example you want to use. In my case: "cd c:\qwt-5.2.0\examples\simple_plot

3. type the following: "qmake -tp vc simple_plot.pro"
This creates a visual studio project file.
You can open this "simple.vcproj" file directly in visual studio and it will compile and build.

emrares
14th August 2009, 12:07
Thanks for the tip. didn't know that :)