首先安裝QT5
然後CMake再Configure後勾選With_QT, Generate後會報錯
CMake Error at cmake/OpenCVFindLibsGUI.cmake:18 (find_package):
Could not find a package configuration file provided by "Qt5" with any of
the following names:
Qt5Config.cmake
qt5-config.cmake
Add the installation prefix of "Qt5" to CMAKE_PREFIX_PATH or set "Qt5_DIR"
to a directory containing one of the above files. If "Qt5" provides a
separate development package or SDK, be sure it has been installed.
Call Stack (most recent call first):
CMakeLists.txt:679 (include)
解決方法是添加Qt5_DIR的标簽, 選擇filepath(不能選擇path) 後,填入Qt5Config.cmake的檔案夾

搜尋qt安裝路徑, 查出Qt5Config.cmake所在檔案夾,我的是D:\service\Qt\Qt5.13.0\5.13.0\msvc2017_64\lib\cmake\Qt5
然後雖然是紅色,不用管它,按generate
成功