QWidget: Must construct a QApplication before a QWidget

There are instances that you download official examples from http://www.vtk.org/Wiki/VTK/Examples/Cxx/Qt. but got error like "QWidget: Must construct a QApplication before a QWidget" during runtime. It is most probably due to the debug and release conflict between Qt libaray and your exe file. Just rebuild your exe file by set CMAKE_BUILD_TYPE to Debug or Release correspondingly. It can be done by modifying CMakefile.txt as
--------------------------------------------
set(CMAKE_BUILD_TYPE Debug) or set(CMAKE_BUILD_TYPE Release)
-------------------------------------------
or running cmake like
-------------------------------------------
cmake -DCMAKE_BUILD_TYPE=Release
-------------------------------------------

VS Code下cmake, c++编译,调试环境的构成步骤

1   下载必须extension      按[Ctrl+Shift+X]打开extension窗口,选择安装"C/C++", "CMake", "CMake Tools" 2   在VSCode下打开作业目录 ...