Qt Include-problem with VS2010

Hello everybody,

I have been programming C++ under Ubuntu with gedit and the terminal using already written makefiles. I am writing programs for Image segmentation/inpainting so I need to read pic's to an array and write arrays to pics (black white-pics for the beginning).

I got some files from my advisor and they worked quite well under Linux. I installed Qt in the terminal with the command
1
2
sudo apt-get -y install qt4-qmake
sudo apt-get -y install libqt4-dev


There were also the files imageIO.h,imageIO.cpp and a Makefile:

1
2
3
4
5
INCLUDE = -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtCore -I/usr/include/qt4
LIB     = -L/usr/lib -lQtGui -lQtCore

test: test.cpp imageIO.cpp
	g++ -o test test.cpp imageIO.cpp $(INCLUDE) $(LIB)



Now I wanted to program with VS2010 on Win7. What do I have to do to tell VS what is written in the makefile?

I downloaded http://qt.nokia.com/downloads/windows-cpp-vs2008 (I hope this is no problem for VS2010? - is another one better? but i didn't find a vs2010 version). Then I simply did a right-click on my project ->properties and then included in the "Includedirectory" the folders QtGui,QtCore and Qt (there was no Qt4 folder).
Futhermore I created in my project a imageIO.h and imageIO.cpp and copied the code from the files to these new imageIO's.

Do you already see grave mistakes? My main

1
2
3
4
5
6
7
8
9
#include "stdafx.h"
#include <iostream>
#include "imageIO.h"

int _tmain(int argc, _TCHAR* argv[])
{
	std::cout<<"HelloWorld\n";
	return 0;
}


I hope you don't grill me for asking this question,...

Thank you very much.

sqrt4


P.S.: Here the code from imageIO.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <string>
using std::string;


// Type for color images
struct RGBt {
    RGBt() : r(0), g(0), b(0) {}
    RGBt(float r1, float g1, float b1) : r(r1), g(g1), b(b1) {}
    RGBt(float a) : r(a), g(a), b(a) {}
    float r;
    float g;
    float b;
};



// Load a scalar image
// returns true if the image is read successfully, false otherwise.
//
// Arguments:
//    filename: image file, can be *.png, *.jpg etc. (any format supported by Qt)
//    image:    image array (memory will be allocated in this function)
//    w:        image width
//    h:        image height
bool loadImage(const string &filename, float *&image, int &w, int &h);


// Load a color image
// returns true if the image is read successfully, false otherwise.
//
// Arguments:
//    filename: image file, can be *.png, *.jpg etc. (any format supported by Qt)
//    image:    image array (memory will be allocated in this function)
//    w:        image width
//    h:        image height
bool loadImage(const string &filename, RGBt *&image, int &w, int &h);


// Save a scalar image
// returns true if the image is saved successfully, false otherwise
//
// Arguments:
//    image:    image array
//    w:        image width
//    h:        image height
//    filename: image file
bool saveImage(const float *image, int w, int h, const string &filename);


// Save a scalar image
// returns true if the image is saved successfully, false otherwise
//
// Arguments:
//    image:    image array
//    w:        image width
//    h:        image height
//    filename: image file
bool saveImage(const RGBt *image, int w, int h, const string &filename);


You started a new "Console Project" in VC++ didn't you...don't do that. Make a new "Blank" project instead and add your own Main.cpp file to it. Then, you can compile normal programs! :D

EDIT: nevermind, I misunderstood the post. See two posts down to guestgulkan's post of correctness.
Last edited on
Yes you are right. Now i started a Blank project and did all steps again. But still wenn i try to run
1
2
3
4
5
6
7
#include<iostream>
#include"imageIO.h"

int main(){
	std::cout<<"Hello World\n";
return 0;
}


he complains about not finding "qtransforms.h"
fatal error C1083: File (Include) cannot be opend: "QtGui/qtransform.h": No such file or directory

But in the folder QtGui there is a qtransform.h and it's content is

#include "../../src/gui/painting/qtransform.h"

And in "src/gui/painting" is a qtransform.h with written code !


But did i "translate" the makefile correct? I mean is there in principle not more to do than going to properties and then include in the includedirectory the folders QtGui,QtCore,Qt ? I found these folders in the folder "C:\Qt\4.7.2\include". I guess these should be the right folders, but I'm not sure.

Thank you
sqrt4
There is a QT plugin for Visual Studio 2008 and for 2010.
You download and install the QT libraries like you did.
Then download the plugin and install it.

You can then create QT projects in Visual Studio in the same way you would create a console program or win32 gui program.
it also integrates QT help, it is easy to add headers and libraries (just bring up the qt properties for the project and click the appropriate checkboxes).
So get the plugin.
Topic archived. No new replies allowed.