PDA

View Full Version : Integrating a .jar in a QT window



Eska
11th June 2012, 16:11
Hi everybody !

I am actually trying to create a GUI using QTCreator on MacOSX. A part of the work I want to do in this UI has already been done in Java, and I detain the executable .jar which launch this application in a new window.

I would like to simply insert the window launched through the .jar in a sub-window of my QT mainwindow (for instance in a specific Qframe).

My code is actually as this :

mainwindow.h


#include<QProcess>

...

Qprocess *PFDprocess;


mainwindow.cpp



...
PFDprocess = new QProcess( );
PFDprocess -> start("java -jar /path/to/my/file.jar");
...



The problem is that the .jar executes in a new window, even if I specify a "parent object" in the constructor of QProcess(---).

Is there a way to specify that every output generated by the QProcess execution can be displayed in a specific area (in the mainwindow), and not in a new window ?

I use QTCreator with QT 4.8.1.

Thank you very much

Eska

yeye_olive
11th June 2012, 16:36
QProcess derives from QIODevice. By default the standard output of the process is bound to the QProcess. Therefore what you can do is:
1. read asynchronously from the QProcess as you would from any QIODevice;
2. interpret the data as text;
3. append the text to a display widget such as QTextEdit.

Eska
11th June 2012, 16:55
Thank you yeye_olive..

I understand that it's possible in order to get text, but my .jar is in fact a whole GUI.

To be more specific, my QT application is a Cockpit for a home-made flight simulator, and the .jar gives a render of a PFD (http://www.albadawi.be/images/PFD%20B747-400.jpg) that is already communicating with my simulation parameters.

The objective would be to inser this java feature in part of the Qt window...

I hope I am clear enough.

Eska

wysota
11th June 2012, 21:47
In a general case this is not possible, In some cases, on some platforms with applications written in a special way this is possible. In your particular case it's probably not, though (unless you use some platform specific API for this).

Eska
12th June 2012, 09:17
Thank you... Then I guess that is not possible...

Maybe it's possible to cheat though, using transparency in the QT window and launching automatically the .jar at the good place in background... I will see...

Thanks a lot... If anyway i find alternative solutions I will add them to this thread.

Eska