Hello. Please how can I make Qt GUI work for geant4 on windows. I built with Qt and when I wanted to try example B1, the Qt GUI did not show and not even listed as one of the UI. Only the OGL widow (below) shows. Please help me out.
Well…you have to install Qt, then build Geant4 from scratch with
cmake, supplying options as set out in the Installation Guide, namely
GEANT4_USE_QT=ON and, possibly,
cmake needs help finding Qt. Have you done all this?
I have Qt installed and it was ON when building geant. It was able to recognise the Qt as shown in the picture below.
Mmmm. Then maybe you are inhibiting the startup of the Qt GUI. It is sensitive to environment (at least on Unix). Also, sensitive to a file
.g4session in the “home” directory.
I speak as a Unix user. Maybe someone who uses Windows can comment further.
How can it be inhibited? I don’t understand.
I rebuilt with visual studio again. Everything went on fine except warning: CODE: C4305, DESCRIPTION (‘argument’: truncation from ‘int’ to ‘bool’), PROJECT (G4OpenGL) and FILE (G4OpenGLQtViewer.cc).
I also had the same situation as you when executing G4 on windows.
I solved it as follows:
In the file of your main (exampleB1.cc), change the line
ui = new G4UIExecutive(argc, argv);
ui = new G4UIExecutive(argc, argv,“qt”);
In fact, the code execute the standard WIN32 UI unless you have setup your environment variables to use the QT UI. If not, you can still ask the code to use the QT UI by adding the keyword of the UI you want to use. In your case, it is QT. If you built G4 correctly with QT, it will work.
Thanks for this, Thomas. I hope this gets you started, Olowoeyo1.
Still, it is strange. If you build with Qt, the Qt GUI should come up by default. The default can be changed by setting environment variables (I don’t recommend that - it is always troublesome keeping track of the environment) or creating
.g4session in your home directory. See How to Set Up an Interactive Session — Book For Application Developers 10.7 documentation. But, by default, the Qt GUI should start up - and if not, maybe we have found a bug. Please check your environment. Let’s try to figure out what’s going on. Let us know what happens.
- you need Qt5 installed. Assuming you use standard Qt Maintenance tool,
verify you install Qt for Visual Studio 64 bit ( msvc2019_64 ).
- Before compile Geant4 and/or examples you need add path to the Qt libraries to
the PATH variables. You can use script provided by Qt
you need just past for your Qt installation.
- You also need setup Visual Studio compiler in this window.
Noe you must be able to compile and run geant4 examples from this widow.
Before run examples you need have geant4 datasets variables defined as it described
in installation guide
Hi semenjuk. How can I ‘setup Visual Studio compiler in this window’?
I will also try the item (2).
You have to use “x86 Native Tools Command Prompt for VS 2019” command from start menu
call c:"\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat"
in you cmd.exe windows which make the settings.
Sorry, use 64 bit windows:
"x64 Native Tools Command Prompt for VS 2019”
Did you add -DCMAKE_PREFIX_PATH at compiling of Geant4. eg. -DCMAKE_PREFIX_PATH=\Qt5\5.15.2\msvc2019_64.
Yes. I added it when I wanted to compile Geant4. I also tried CMAKE GUI and added the path of QT to it
I have a successful for making Qt GUI. But I had similar situation.
Please check Qt configurations. This picture is my configurations. I can make Qt GUI by this configurations.
Hello MoritaMasaki. Please is it possible the show the content of the lower part (‘Developer and Designer Tools’)? I am modifying the installation of the Qt
Hello everyone. I have modified the Qt to reflect the suggestion of @MoritaMasaki and got this warning after building Geant4 (C4305: ‘argument’: truncation from ‘int’ to ‘bool’) and it identifies OpenGLQtViewer.cc.
Can it be the reason for the problem?
After installing Geant4, I was able to get the following without any error:
The lower part is default.
Which “cmake” do you use? You may have two cmake (cmake and VS). I use “cmake” of VS and it’s successful.
I make a procedure in Qiita but in Japanese.
For VS, compiling from “Developer Command Prompt for VS2019”.
When you execute “cl” and show like
Microsoft (R) C/C++ Optimizing Compiler Version > 19.00.23026 for x86
Copyright (C) Microsoft Corporation. All rights > reserved.
usage: cl [ option… ] filename… [ /link > > >linkoption… ]
, this means “cmake” is VS.
Hi @MoritaMasaki I don’t understand this