Geant4 Without built in UI

Hello I have project based on Qt 5 and Geant4 I already created my Application Main Window
in Qt independent from Geant4, I just wanna use Geant4 Terminal and put it to my MainWindow’s some widget, I already tried to adopting G4UImanager, G4UIExecutive, G4UIsession to QWidget and adding them to my MainWindow’s some widget, but it doesnt help. OpenGLStroedX still popping in another window.
I am new in Geant4 please help.

Not sure I understand. You don’t have to build Geant4 with Qt or OpenGL, and even if you have, you don’t have to use them.

Yes you didnt undersand, :slight_smile: I have an GDML Viewer App and I want to use geant4 for visualization but not for the user interface I just need to fix the opengl viewer to my Qt App’s main window.

Still not sure I understand.

If you wish to visualise a GDML file in Geant4 you could use examples/extended/persistency/gdml/G01.

If you don’t want the Qt GUI, see How to select interface in your applications.

I wish to use OGLSQt but it doesnt work without G4UIQt, I dnt wanna use G4UIQt

You don’t have to use G4UIQt (see How to Set Up an Interactive Session — Book For Application Developers 10.7 documentation), but I’m afraid you cannot use OGLSQt without it.

You will have to build Geant4 with one of the other graphics drivers - OGLSX (using CMake option -DGEANT4_USE_OPENGL_X11=ON) or OGLSXm if you have Motif (additionally -DGEANT4_USE_XM=ON) or OI if you have the Open Inventor libraries (but they are tricky to install and CMake needs special instructions). OGLSX opens a non-interactive window, but you can change viewpoint and zoom, etc., with Geant4 commands, e.g., /vis/viewer/zoom.

Dear experts,
I believe what sufuk is trying to do is to embed GEANT4 in his own QT application.
If this is what he tries to do, I am also interested in this topic.
I would like to be able to insert a Geant4 terminal and a Geant4 viewer inside a QT object. In such way, the GEANT4 windows (from QT executive or WIN32 executive or others) do not pop out but inside my QT application.
I have tried to redirect G4cout to a QtPlainTextEdit and the OpenGL viewer to a QtOpenGLWidget without any success.
Is there an example or a tutorial to do so?
Thanks a lot

1 Like

Dear experts,
I did not find any example in the geant4 example folder. However I believe I could use the class that constructs the qt windows as an example.
could you please let me know which part of the source code is responsible for the qt windows creation, the terminal and the opengl browser so that I can integrate it in my own qt window.
Thank you.

Ah! This seems to be an increasingly common request. I am not a Qt expert but I can point you to a recent post - OpenGL driver for windows. Does this help?

If you want to jump into the Geant4 source code, you’re on your own!! :slight_smile: But all the Qt source code is in geant4/source/interfaces and visualization. If you make progress, it may help us to know what you have done so that we could offer this option in future.

John

Thats exactly what I want to do @froz1233

@allison Sadly no it is too much for me, its sad thing to say Geant4 currently does not support that. Many frameworks and toolkits started to become fully compatible with Qt but it seems Geant4 is a latecomer in this kind of stuff.