# Qt GUI for windows

**URL:** <https://geant4-forum.web.cern.ch/t/qt-gui-for-windows/6483>\
**Category:** Recording, Visualizing and Persisting Data\
**Created:** [November 8, 2021, 12:39pm UTC](https://geant4-forum.web.cern.ch/t/qt-gui-for-windows/6483 "2021-11-08T12:39:32Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![olowoeyo1](https://geant4-forum.web.cern.ch/letter_avatar_proxy/v4/letter/o/77aa72/32.png) [@olowoeyo1](https://geant4-forum.web.cern.ch/u/olowoeyo1)\
**Post date:** [November 8, 2021, 12:39pm UTC](https://geant4-forum.web.cern.ch/t/qt-gui-for-windows/6483/1 "2021-11-08T12:39:32Z")

</div>

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.

 ![IMG_20211023_220837_397](https://geant4-forum.web.cern.ch/uploads/default/original/2X/1/16a7834fc0356f5e5718295eff1e4cdbd364909e.jpeg)

---

<div class="post-metadata">

**Author:** ![allison](https://geant4-forum.web.cern.ch/letter_avatar_proxy/v4/letter/a/90db22/32.png) [@allison](https://geant4-forum.web.cern.ch/u/allison)\
**Post date:** [November 8, 2021, 1:08pm UTC](https://geant4-forum.web.cern.ch/t/qt-gui-for-windows/6483/2 "2021-11-08T13:08:16Z")

</div>

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_PREFIX_PATH` if `cmake` needs help finding Qt. Have you done all this?

---

<div class="post-metadata">

**Author:** ![olowoeyo1](https://geant4-forum.web.cern.ch/letter_avatar_proxy/v4/letter/o/77aa72/32.png) [@olowoeyo1](https://geant4-forum.web.cern.ch/u/olowoeyo1)\
**Post date:** [November 8, 2021, 1:13pm UTC](https://geant4-forum.web.cern.ch/t/qt-gui-for-windows/6483/3 "2021-11-08T13:13:15Z")

</div>

I have Qt installed and it was ON when building geant. It was able to recognise the Qt as shown in the picture below.

 ![IMG_20211105_195134_563](https://geant4-forum.web.cern.ch/uploads/default/original/2X/7/73ed268f0eadf7dbfad01581cb9aa63e5f5fc1c1.jpeg)

---

<div class="post-metadata">

**Author:** ![allison](https://geant4-forum.web.cern.ch/letter_avatar_proxy/v4/letter/a/90db22/32.png) [@allison](https://geant4-forum.web.cern.ch/u/allison)\
**Post date:** [November 8, 2021, 5:14pm UTC](https://geant4-forum.web.cern.ch/t/qt-gui-for-windows/6483/4 "2021-11-08T17:14:14Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![olowoeyo1](https://geant4-forum.web.cern.ch/letter_avatar_proxy/v4/letter/o/77aa72/32.png) [@olowoeyo1](https://geant4-forum.web.cern.ch/u/olowoeyo1)\
**Post date:** [November 8, 2021, 5:53pm UTC](https://geant4-forum.web.cern.ch/t/qt-gui-for-windows/6483/5 "2021-11-08T17:53:06Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![froz1233](https://geant4-forum.web.cern.ch/user_avatar/geant4-forum.web.cern.ch/froz1233/32/1455_2.png) [@froz1233](https://geant4-forum.web.cern.ch/u/froz1233)\
**Post date:** [November 9, 2021, 11:14am UTC](https://geant4-forum.web.cern.ch/t/qt-gui-for-windows/6483/6 "2021-11-09T11:14:50Z")

</div>

Dear Olowoeyo1,  
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);

by

> 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.  
Best

---

<div class="post-metadata">

**Author:** ![allison](https://geant4-forum.web.cern.ch/letter_avatar_proxy/v4/letter/a/90db22/32.png) [@allison](https://geant4-forum.web.cern.ch/u/allison)\
**Post date:** [November 9, 2021, 11:56am UTC](https://geant4-forum.web.cern.ch/t/qt-gui-for-windows/6483/7 "2021-11-09T11:56:35Z")

</div>

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](https://geant4-userdoc.web.cern.ch/UsersGuides/ForApplicationDeveloper/html/GettingStarted/graphicalUserInterface.html#how-to-select-interface-in-your-applications). 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.

John

---

<div class="post-metadata">

**Author:** ![olowoeyo1](https://geant4-forum.web.cern.ch/letter_avatar_proxy/v4/letter/o/77aa72/32.png) [@olowoeyo1](https://geant4-forum.web.cern.ch/u/olowoeyo1)\
**Post date:** [November 9, 2021, 12:11pm UTC](https://geant4-forum.web.cern.ch/t/qt-gui-for-windows/6483/8 "2021-11-09T12:11:13Z")

</div>

Hello everyone. I built the exampleB1 again, but I got the following error messages:

 ![IMG_20211109_125720_098](https://geant4-forum.web.cern.ch/uploads/default/original/2X/1/16c2df57b545aacb74e20d3465bfb4d8e661f5b1.jpeg)  
 ![IMG_20211109_125758_249](https://geant4-forum.web.cern.ch/uploads/default/original/2X/e/e8913afa2fe6fe3fb066576b171eaccb0bc8afd6.jpeg)  
 ![IMG_20211109_125807_345](https://geant4-forum.web.cern.ch/uploads/default/original/2X/d/d92593cee92347b3a6a1adc690282329a77a6045.jpeg)  
 ![IMG_20211109_125816_902](https://geant4-forum.web.cern.ch/uploads/default/original/2X/4/4f8b4f70a90830382637a84daddd5ea60c0dfcfb.jpeg)

---

<div class="post-metadata">

**Author:** ![semenjuk](https://geant4-forum.web.cern.ch/letter_avatar_proxy/v4/letter/s/e9bcb4/32.png) [@semenjuk](https://geant4-forum.web.cern.ch/u/semenjuk)\
**Post date:** [November 15, 2021, 2:34pm UTC](https://geant4-forum.web.cern.ch/t/qt-gui-for-windows/6483/9 "2021-11-15T14:34:37Z")

</div>

1. you need Qt5 installed. Assuming you use standard Qt Maintenance tool,  
verify you install Qt for Visual Studio 64 bit ( msvc2019\_64 ).
2. 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  
call \Qt5\5.15.2\msvc2019\_64\bin\qtenv2.bat  
you need just past for your Qt installation.
3. 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

---

<div class="post-metadata">

**Author:** ![olowoeyo1](https://geant4-forum.web.cern.ch/letter_avatar_proxy/v4/letter/o/77aa72/32.png) [@olowoeyo1](https://geant4-forum.web.cern.ch/u/olowoeyo1)\
**Post date:** [November 15, 2021, 5:08pm UTC](https://geant4-forum.web.cern.ch/t/qt-gui-for-windows/6483/10 "2021-11-15T17:08:32Z")

</div>

Hi semenjuk. How can I ‘setup Visual Studio compiler in this window’?  
I will also try the item (2).

Thank you

---

<div class="post-metadata">

**Author:** ![semenjuk](https://geant4-forum.web.cern.ch/letter_avatar_proxy/v4/letter/s/e9bcb4/32.png) [@semenjuk](https://geant4-forum.web.cern.ch/u/semenjuk)\
**Post date:** [November 15, 2021, 5:46pm UTC](https://geant4-forum.web.cern.ch/t/qt-gui-for-windows/6483/11 "2021-11-15T17:46:57Z")

</div>

You have to use “x86 Native Tools Command Prompt for VS 2019” command from start menu  
or  
call c:"\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat"  
in you cmd.exe windows which make the settings.

---

<div class="post-metadata">

**Author:** ![semenjuk](https://geant4-forum.web.cern.ch/letter_avatar_proxy/v4/letter/s/e9bcb4/32.png) [@semenjuk](https://geant4-forum.web.cern.ch/u/semenjuk)\
**Post date:** [November 15, 2021, 5:53pm UTC](https://geant4-forum.web.cern.ch/t/qt-gui-for-windows/6483/12 "2021-11-15T17:53:15Z")

</div>

Sorry, use 64 bit windows:  
"x64 Native Tools Command Prompt for VS 2019”

---

<div class="post-metadata">

**Author:** ![MoritaMasaki](https://geant4-forum.web.cern.ch/user_avatar/geant4-forum.web.cern.ch/moritamasaki/32/3566_2.png) [@MoritaMasaki](https://geant4-forum.web.cern.ch/u/MoritaMasaki)\
**Post date:** [November 22, 2021, 8:07am UTC](https://geant4-forum.web.cern.ch/t/qt-gui-for-windows/6483/13 "2021-11-22T08:07:00Z")

</div>

Did you add -DCMAKE\_PREFIX\_PATH at compiling of Geant4. eg. -DCMAKE\_PREFIX\_PATH=\Qt5\5.15.2\msvc2019\_64.

---

<div class="post-metadata">

**Author:** ![olowoeyo1](https://geant4-forum.web.cern.ch/letter_avatar_proxy/v4/letter/o/77aa72/32.png) [@olowoeyo1](https://geant4-forum.web.cern.ch/u/olowoeyo1)\
**Post date:** [November 22, 2021, 8:54am UTC](https://geant4-forum.web.cern.ch/t/qt-gui-for-windows/6483/14 "2021-11-22T08:54:40Z")

</div>

Yes. I added it when I wanted to compile Geant4. I also tried CMAKE GUI and added the path of QT to it

---

<div class="post-metadata">

**Author:** ![MoritaMasaki](https://geant4-forum.web.cern.ch/user_avatar/geant4-forum.web.cern.ch/moritamasaki/32/3566_2.png) [@MoritaMasaki](https://geant4-forum.web.cern.ch/u/MoritaMasaki)\
**Post date:** [November 22, 2021, 2:46pm UTC](https://geant4-forum.web.cern.ch/t/qt-gui-for-windows/6483/15 "2021-11-22T14:46:47Z")

</div>

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.

 ![68747470733a2f2f71696974612d696d6167652d73746f72652e73332e61702d6e6f727468656173742d312e616d617a6f6e6177732e636f6d2f302f313237383731302f61613436346338312d316261642d623835382d393939392d6431333733396139373565332e706e6](https://geant4-forum.web.cern.ch/uploads/default/original/2X/b/be5a431c17d9d512d7d6c0ef1ff0f4c8b76f6674.png)

---

<div class="post-metadata">

**Author:** ![olowoeyo1](https://geant4-forum.web.cern.ch/letter_avatar_proxy/v4/letter/o/77aa72/32.png) [@olowoeyo1](https://geant4-forum.web.cern.ch/u/olowoeyo1)\
**Post date:** [November 23, 2021, 9:54am UTC](https://geant4-forum.web.cern.ch/t/qt-gui-for-windows/6483/16 "2021-11-23T09:54:49Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![olowoeyo1](https://geant4-forum.web.cern.ch/letter_avatar_proxy/v4/letter/o/77aa72/32.png) [@olowoeyo1](https://geant4-forum.web.cern.ch/u/olowoeyo1)\
**Post date:** [November 23, 2021, 5:28pm UTC](https://geant4-forum.web.cern.ch/t/qt-gui-for-windows/6483/17 "2021-11-23T17:28:59Z")

</div>

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?

 ![IMG_20211123_180445_833](https://geant4-forum.web.cern.ch/uploads/default/original/2X/a/a6d5757c2121ed5447db794c52488957c186eb43.jpeg)  
 ![IMG_20211123_180453_485](https://geant4-forum.web.cern.ch/uploads/default/original/2X/a/ab347908123dfdd47b6aaadeebad3cf967571836.jpeg)

After installing Geant4, I was able to get the following without any error:

 ![IMG_20211123_181759_211](https://geant4-forum.web.cern.ch/uploads/default/original/2X/b/bc6177ded68155e9779b91e295cfbf8f69d7cf15.jpeg)  
 ![IMG_20211123_181547_549](https://geant4-forum.web.cern.ch/uploads/default/original/2X/6/6aa88c9311a140e6ac2c3e3e5f1dd19df64fa882.jpeg)

---

<div class="post-metadata">

**Author:** ![MoritaMasaki](https://geant4-forum.web.cern.ch/user_avatar/geant4-forum.web.cern.ch/moritamasaki/32/3566_2.png) [@MoritaMasaki](https://geant4-forum.web.cern.ch/u/MoritaMasaki)\
**Post date:** [December 8, 2021, 12:32pm UTC](https://geant4-forum.web.cern.ch/t/qt-gui-for-windows/6483/18 "2021-12-08T12:32:14Z")

</div>

The lower part is default.

---

<div class="post-metadata">

**Author:** ![MoritaMasaki](https://geant4-forum.web.cern.ch/user_avatar/geant4-forum.web.cern.ch/moritamasaki/32/3566_2.png) [@MoritaMasaki](https://geant4-forum.web.cern.ch/u/MoritaMasaki)\
**Post date:** [December 8, 2021, 12:40pm UTC](https://geant4-forum.web.cern.ch/t/qt-gui-for-windows/6483/19 "2021-12-08T12:40:10Z")

</div>

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.

> **[Geant4をWindowsにインストールし、Qtを利用して表示する - Qiita](https://qiita.com/m_moriti/items/cac199fd9a4d7c821044)**
>
> 高エネルギー粒子のシミュレーションとして用いられるGeatn4をWindowsにインストールして、Qtで表示する方法をまとめる。標準では、OpenGLを使用するのだが、WindowsではOpenGLの表示が正しくないこともあり、汎用性...

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.

---

<div class="post-metadata">

**Author:** ![olowoeyo1](https://geant4-forum.web.cern.ch/letter_avatar_proxy/v4/letter/o/77aa72/32.png) [@olowoeyo1](https://geant4-forum.web.cern.ch/u/olowoeyo1)\
**Post date:** [December 8, 2021, 1:17pm UTC](https://geant4-forum.web.cern.ch/t/qt-gui-for-windows/6483/20 "2021-12-08T13:17:40Z")

</div>

Hi @MoritaMasaki I don’t understand this

[Next page](https://geant4-forum.web.cern.ch/t/qt-gui-for-windows/6483.md?page=2)
