Configuration, compilation and installation of vtk8.1 in qt5.9

To implement RealSense’s PCL point cloud display, VTK support is required. Since the entire platform is implemented in the Qt environment, VTK is compiled as a Qt plug-in. The whole process is not complicated, most of the online articles are not complete, their own carding, share out, I hope this is the last article you read under Qt install VTK plug-in article.

0 Compiling Environment

0.1 Package and version

Qt5.9.4

msvc2015_64

VS2015

VTK 8.1.1

https://www.vtk.org/download/

cmake3.11.3

Download

0.2 Local directory description

Qt5.9.4 msvc64 directory

C: \ Qt \ Qt5.9.4\5.9.4 \ msvc2015_64

VTK decompression directory

C: \ WS \ VTK \ VTK – 8.1.1

VTK Build directory

C: \ WS, VTK, VTK – 8.1.1, build

VTK installation directory (containing compiled inc,lib)

C:\vtk

1 the VTK download

1.1 Download VTK-8.1.1.zip,VTKData-8.1.1.zip files

1.2 unzip

Select unzip to the current directory, the two files will be automatically assembled in the vtk-8.1.1 folder after unzip.

2. Configure VTK for Qt

2.1 Start CMake, specify the source directory and compile directory, and click Configure.

2.2 Specify the VS version

64-bit Visual Studio 14 2015 Win64, 32-bit Visual Studio 14 2015. Click Finish and wait for the configuration to complete.

2.3 Configure compilation options (1)

BUILD options

Select Build_Examples, Build_Shared_Libs, and Build_Testing.

Note:

It is not recommended to select Documentation, which requires that Doxygen be installed first.

It is not recommended to remove TESTING as this will cause errors to be reported at the later VS compilation stage and header files to be modified.


VTK installation directory

Include, lib, DLL (bin), and so on.


VTK_Group_Qt

Set the target environment for compilation to Qt.


Once you have done all three Settings, click Configure.

2.4 Configure compilation options (2)

After the first configuration is complete, the user is prompted for Qt5_DIR and VKT_QT_VERSION.

Amend the Qt5_DIR to C:/Qt/Qt5.9.4 5.9.4 msvc2015_64/lib/cmake/Qt5.

Set VKT_QT_VERSION to 5.

Click Configure again to continue.

2.5 the Generate engineering

When the configuration is successful, a Configure Done prompt appears. Click Generate to build the project.

2.6 Start VS2015 and start compiling

Generating done indicates that VS2015 project has been generated successfully. Click Open Project, VS2015 will start and Open the Project.

3 Compile VTK project in VS2015

3.1 build

After opening the project, the default startup item is ALL_BUILD, and you can directly select Build. Both the Release and Debug versions need to be built, so two compilations are performed.


It’s been a long time, long time… . And it worked.

3.2 installation

Select Install, right-click Build.


Install OK.

3.3 Compiling results

The results of VS2015 compilation include four parts.

1. Include does not distinguish between Release and Debug versions

2. Lib does not discriminate versions

3. The DLL selects debug and release versions according to the input configuration.

4. Plugin DLL is only available in Release versions.

The four compiled results are placed in two locations.

The.h and.lib files are stored in the C:\VTK directory (step 2.3 configuration). Please do not use DLL files under C:\VTK, because there is no distinction between release and debug.


The.dll file is placed in C:\WS\ VTK \ vtk-8.1.1 \build\bin (step 2.1 configuration).

3.4 Compile test successfully (you can skip this step if you don’t want to test)

Compiled DLLs and EXEs in vtk-8.1.1\ build\bin\Release\

Copy qt5gui.dll, qt5core. DLL, qt5Widgets. DLL from the Qt directory to this directory or the debug directory. (Environment variables can also be configured)

Run qtvtkrenderWindows.exe in this directory, and see as shown in the figure, the compilation of exe is successful after startup.

4. Install the QVTKWidget plug-in for Qt Designer

4.1 installation

Will be C: \ WS, VTK, VTK – 8.1.1, build \ bin \ Release \
Copy the QVTKWidgetPlugin.dll to the C:\Qt\Qt5.9.4\5.9.4\msvc2015_64\plugins\designer\ directory.

Note: Be sure to copy the Release version.

4.2 validation

Start Qt Designer.

There are two versions, usually 32-bit at the top and 64-bit at the bottom. Select according to the compiled version.


At the bottom of the left-hand Widget Box you can see the QVTKWidget description installed successfully.

5 supplementary

5.1 Use VTK in VS2015 environment

You need to install the Qt Visual Studio Tools extension in the VS2015 extension and update. Note that QTPackage cannot use the QVTKWidget, do not install.

Installation steps


1. Select Extend and Update from the Tools menu

2. Select Qt Visual Studio Tools for installation online. There is also a QTPackage that cannot be used, do not install it.


3. After successful installation, Qt VS Tools will appear on the menu. Click Launch Qt Designer to see it.

5.2 Use VTK in the Qt Creator environment

Designer in Qt Creator environment cannot see QVTKWidget, so it cannot be dragged and dropped directly. You need to drag and drop QWidget first, and then select QWidget to be promoted to QvtkWidget.


Read More: