Qt Creator Debugging Tools for Windows

After a fresh installation of Qt and Visual Studio 2015 I had some problems in configuring developing kits in the Qt Creator application. The main problem was that it could not find any debugger, so here is a small guide where you can save a little bit more time to setup all correctly:

  1. Download and install Microsoft Visual Studio Community 2015
  2. Download and install Qt
  3. Download the full package Windows 10 SDK
  4. After download execute the setup and select only ‘Debugging Tools for Windows’ for installation

Qt QML Compile Sources for OpenGL Visual Studio 2015

To build the Qt sources by your own you have to do the following steps:

  1. Download and install Visual Studio 2015. I took the Community edition.
  2. Download and install Qt. I took the Visual Studio 2015 Desktop version.
  3. Download and install Python. It has to be installed to compile QML.
  4. Open the Visual Studio ‘Developer Command Prompt for VS2015’: Windows Start – Visual Studio 2015 – Developer Command Prompt for VS2015
  5. Than run the following command chain
    >> cd "Path/to/the/Qt/source/folder/" (in my case C:\Qt\5.7\Src)
    
    Follow this link to get more information about the configuration parameters. In my case I recompile the source code to use OpenGL.
    
    >> configure -opengl -desktop -platform win32-msvc2015
    
    The supported platform parameter could be found in this directory: 'C:\Qt\5.7\msvc2015_64\mkspecs'. The parameter title is the directory name.
    
    >> nmake
    
    Now lay back and drink a coffee. It will at least last a hour...
  6. For using OpenGL insert the following to your pro file
    QT += qml quick opengl
    LIBS += 'C:/Program Files (x86)/Windows Kits/10/Lib/10.0.14393.0/um/x64/OpenGL32.Lib' (in my case, just search for the OpenGL32.Lib)
  7. Congratulations! Now you can start with QML and OpenGL!

OpenCV and Universal Windows Platform UWP

To get OpenCV running on Windows 10 via an UWP project you have to do the following steps:

  • Download and install
    latest Microsoft Visual Studio 2015 Community (or an earlier version, must support UWP)
    latest OpenCV (this tutorial with 3.4.1)
    latest CMake (this tutorial with 3.1)
  • Open CMake
    CMakeGUI OpenCV
    I unchecked BUILD_EXAMPLES, BUILD_PERF_TESTS, BUILD_TESTS.
    Press configure and select Visual Studio 2015 x64. After that generate the project by pressing ‘Generate’. (If you plan to compile the ARM Version, only static libraries can be build, simply uncheck BUILD_SHARED_LIBS).
  • Open the user defined CMake project folder and open the created project solution (*.sln) file. Build both – the debug and the release version. This should work without and problems. After I built OpenCV I copied the debug and release dlls in a separate bin folder and the libs also in a separate libs folder. Because of the OpenCV separation with the suffix d for debug both (debug and release) can exist in one directory.
  • Create a new Visual Studio 2015 Project and select ‘Blank App (Universal Windows)’Visual Studio 2015 OpenCV Project
  • Download and modify the paths inside the file with your favorite text editor: Visual Studio User Defined Properties. This separate properties file can be modified very easily and can be shared with other projects too.
  • Add the properties file to your current Visual Studio 2015 project.
    Visual Studio 2015 Property Window
    Visual Studio 2015 Properties
    You can do this again for the Debug | x64 too. Simply right click on the build type and select ‘Add Existing Property Sheet’. Choose the opencv_x64.probs file again. A macro inside the file will switch between debug and release configuration automatically.
  • Here is the content of my MainPage.cpp
    //
    // MainPage.xaml.cpp
    // Implementation of the MainPage class.
    //
    #include “pch.h”
    #include “MainPage.xaml.h”
    #include <opencv2\core.hpp>
    #include <opencv2\imgcodecs.hpp>
    #include <opencv2\imgproc.hpp>
    #include <robuffer.h>
    using namespace CVProj;
    using namespace Platform;
    using namespace Windows::Foundation;
    using namespace Windows::Foundation::Collections;
    using namespace Windows::UI::Xaml;
    using namespace Windows::UI::Xaml::Controls;
    using namespace Windows::UI::Xaml::Controls::Primitives;
    using namespace Windows::UI::Xaml::Data;
    using namespace Windows::UI::Xaml::Input;
    using namespace Windows::UI::Xaml::Media;
    using namespace Windows::UI::Xaml::Navigation;
    using namespace Windows::UI::Xaml::Media::Imaging;
    using namespace Windows::Storage::Streams;
    using namespace Microsoft::WRL;
    MainPage::MainPage()
    {
    InitializeComponent();
     cv::Mat input;
    input = cv::imread(“Image file from the ‘Assets’ folder of your project.“);
     cv::Mat img = cv::Mat(input.rows, input.cols, CV_8UC4);
    cv::cvtColor(input, img, CV_BGR2BGRA);
     cv::resize(img, img, cv::Size(640, 480));
     BitmapImage ^bitImg = ref new BitmapImage();
     WriteableBitmap;
    WriteableBitmap^ wbmp = ref new WriteableBitmap(img.cols, img.rows);
    IBuffer^ buffer = wbmp->PixelBuffer;
    unsigned char* dstPixels;
    ComPtr<IBufferByteAccess> pBufferByteAccess;
    ComPtr<IInspectable> pBuffer((IInspectable*)buffer);
    pBuffer.As(&pBufferByteAccess);
    pBufferByteAccess->Buffer(&dstPixels);
    memcpy(dstPixels, img.data, img.step.buf[1] * img.cols * img.rows);
    cvImg->Source = wbmp;
    }
  • Add this entry to your MainPage.xaml file
    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <Image Name="cvImg"></Image>
    </Grid>
  • Now it should compile without any problems otherwise you do have to check your properties file.
  • You successfully created a Universal Windows Application with OpenCV support!