Download the Qt-opensource-windows-x86-mingw482_opengl-5.3.1.exe file to the official website, execute the file, select the default installation to achieve QT installation (installed in the root directory of the C drive), The file encapsulates QT libraries,qt Creator, where qt Creator is the 3.1.2 version.
To the official website http://opencv.org/downloads.html download opencv for Windows2.4.9 version-Opencv-2.4.9.exe. Execute the file, unzip it to the appropriate directory, I put it in the root of the C-drive directory, that is, C:\OPENCV.
Download the cmake-3.0.1-win32-x86.exe file in http://www.cmake.org/cmake/resources/software.html. Install CMake, installed in the C:\CMake directory.
Set the environment variable of the system, that is, add C:\Qt\Qt5.3.1\Tools\MinGW\bin to the PATH environment variable of the system, because the library under that directory will be used during CMake compilation.
Click on the desktop cmake (Cmake-gui) icon, execute cmake, where is the source Code Bar and where to build thebinaries column c:/opencv/soureces to c:/opencv/mingw. C:/OPENCV/MINGW is the directory in which the compiled library file is stored and needs to be created by itself. Then click the configure button, open a new window, select Generator MinGW under Specify the makefiles for this project, and then select Specify Native compilers, click next button, open a new window, in c a column filled c:/qt/qt5.3.1/ Tools/mingw482_32/bin/gcc.exe, in c++ column, fill in c:/qt/qt5.3.1/tools/mingw482_32/ Bin/g++.exe,fortran not fill in. Then click finish button to start the configuration, this will appear similar to the following error prompt:
CMake Error:cmake was unable to the find Abuild program corresponding to "MinGW makefiles". Cmake_make_program is not set. You probably need to select a different buildtool.
CMake Error:cmake was unable to the find Abuild program corresponding to "MinGW makefiles". Cmake_make_program is not set. You probably need to select a different buildtool.
CMake Error:error Required internal cmakevariable not set, CMake May is not being built correctly.
Missing variable is:
Cmake_cxx_compiler_env_var
CMake error:could not find CMake modulefile:c:/opencv/mingw/cmakefiles/3.0.1/cmakecxxcompiler.cmake
CMake Error:error Required internal cmakevariable not set, CMake May is not being built correctly.
Missing variable is:
Cmake_c_compiler_env_var
CMake error:could not find CMake modulefile:c:/opencv/mingw/cmakefiles/3.0.1/cmakeccompiler.cmake
Configuring incomplete, Errors occurred!
Find an item named Cmake_make_program and fill it with value as c:/qt/qt5.3.1/tools/mingw482_32/bin/ Mingw32-make.exe can be. Click Configure again without prompting for any errors that indicate a successful configuration.
We also need to add Qt, find with , put it under the with_qt and With_opengl selected, again Configure. An error message similar to the following will appear:
CMake Error atc:/cmake/share/cmake-3.0/modules/findqt4.cmake:1316 (message):
Found unsuitable qt version "" From NOTFOUND, this coderequires QT 4.x
Call Stack (most recent call first):
Cmake/opencvfindlibsgui.cmake:34 (Find_package)
cmakelists.txt:466 (include)
Find qt_qmake_executable, its value is filled in:c:/qt/qt5.3.1/5.3/mingw482_32/bin/qmake.exe
Find Qt_mkspecs_dir, its value is filled in:c:/qt/qt5.3.1/5.3/mingw482_32/mkspecs
Find Qt_qtcore_library_debug, its value is filled in:c:/qt/qt5.3.1/5.3/mingw482_32/bin/qt5cored.dll
Find Qt_qtcore_library_release, its value is filled in as c:/qt/qt5.3.1/5.3/mingw482_32/bin/qt5core.dll
Find Qt_qtcore_include_dir, its value is filled in as c:/qt/qt5.3.1/5.3/mingw482_32/include/qtcore/5.3.1/qtcore
Click Configure again, and an error similar to the following will appear:
CMake Error atc:/cmake/share/cmake-3.0/modules/findqt4.cmake:1316 (message):
Found unsuitable Qt version "5.3.1" from
C:/qt/qt5.3.1/5.3/mingw482_32/bin/qmake.exe, this code requires QT 4.x
Call Stack (most recent call first):
Cmake/opencvfindlibsgui.cmake:34 (Find_package)
cmakelists.txt:466 (include)
found under ungrouped entries Qt5concurrent_dir,qt5core_dir,qt5gui_dir, Qt5test_dir,qt5widgets_ DIR,Qt5opengl_dir, their value is filled in as:
C:/qt/qt5.3.1/5.3/mingw482_32/lib/cmake/qt5concurrent
C:/qt/qt5.3.1/5.3/mingw482_32/lib/cmake/qt5core
C:/qt/qt5.3.1/5.3/mingw482_32/lib/cmake/qt5gui
C:/qt/qt5.3.1/5.3/mingw482_32/lib/cmake/qt5test
C:/qt/qt5.3.1/5.3/mingw482_32/lib/cmake/qt5widgets
C:/qt/qt5.3.1/5.3/mingw482_32/lib/cmake/qt5opengl
Configure again, when the configuration is complete, no error prompts occur. Although there will be many warnings, such as this warning are for project developers. Use-wno-dev to suppress it., but do not go to the tube, press Generate. when the Generate is complete, close the cmake window.
Open the system's command terminal, enter the C:\opencv\MinGW directory, execute the mingw32-make command, which takes a while, after the command executes, then executes the mingw32-make install command. This allows the OpenCV library file for Qt to be generated.
Add the system's PATH environment variable again, as follows:C:\qt\qt5.3.1\5.3\mingw482_32\bin;c:\opencv\mingw\bin.
Later , when we compile OpenCV with Qt creator , after creating a new project, we also need to add the following statements inside the project file. Pro file for the project:
Includepath+=c:\opencv\build\include\opencv\
C:\opencv\build\include\opencv2\
C:\opencv\build\include
LIBS+=c:\opencv\mingw\lib\libopencv_calib3d249.dll.a\
c:\opencv\MinGW\lib\libopencv_contrib249.dll.a\
c:\opencv\MinGW\lib\libopencv_core249.dll.a\
c:\opencv\MinGW\lib\libopencv_features2d249.dll.a\
c:\opencv\MinGW\lib\libopencv_flann249.dll.a\
c:\opencv\MinGW\lib\libopencv_gpu249.dll.a\
c:\opencv\MinGW\lib\libopencv_highgui249.dll.a\
c:\opencv\MinGW\lib\libopencv_imgproc249.dll.a\
c:\opencv\MinGW\lib\libopencv_legacy249.dll.a\
c:\opencv\MinGW\lib\libopencv_ml249.dll.a\
c:\opencv\MinGW\lib\libopencv_objdetect249.dll.a\
C:\OPENCV\MINGW\LIB\LIBOPENCV_VIDEO249.DLL.A
Complete!
http://blog.csdn.net/zhaocj/article/details/38944037
Win7 under the qt5.3.1+opencv2.4.9 build environment (many Opencv2.4.9 source analysis blog)