Error using Qt in window

I think CMake is finding the wrong install root for Qt. The key lines in the CMakeCache.txt are:

//The directory containing a CMake configuration file for Qt5Core.
Qt5Core_DIR:PATH=C:/Qt/5.15.0/mingw81_64/lib/cmake/Qt5Core

//The directory containing a CMake configuration file for Qt5Gui.
Qt5Gui_DIR:PATH=C:/Qt/5.15.0/mingw81_64/lib/cmake/Qt5Gui

//The directory containing a CMake configuration file for Qt5OpenGL.
Qt5OpenGL_DIR:PATH=C:/Qt/5.15.0/mingw81_64/lib/cmake/Qt5OpenGL

//The directory containing a CMake configuration file for Qt5PrintSupport.
Qt5PrintSupport_DIR:PATH=C:/Qt/5.15.0/mingw81_64/lib/cmake/Qt5PrintSupport

//The directory containing a CMake configuration file for Qt5Widgets.
Qt5Widgets_DIR:PATH=C:/Qt/5.15.0/mingw81_64/lib/cmake/Qt5Widgets

Which is Qt for the MinGW toolchain. For use with Visual Studio, those paths (I think) should begin with something like C:/Qt/5.15.0/msvc2019_64/. If that directory (C:/Qt/5.15.0/msvc2019_64/) is present on your system, then you can try:

  1. delete the CMakeCache.txt file
  2. Re-run CMake as you did before but with one additional argument, -DCMAKE_PREFIX_PATH="C:/Qt/5.15.0/msvc2019_64/"
    cmake -DCMAKE_INSTALL_PREFIX="%HOMEPATH%\Geant4\geant4_10_06-install"  -DGEANT4_INSTALL_DATA=ON - DGEANT4_USE_QT=ON -DGEANT4_USE_OPENGL_WIN32=ON -DCMAKE_PREFIX_PATH="C:/Qt/5.15.0/msvc2019_64/" "%HOMEPATH%\Geant4\geant4_10_06"
    

This should point CMake to the right place (I don’t know why it would pick up MinGW first), so check the CMakeCache.txt for those paths first, then try rebuilding.