Actually, there may be a solution to this, but it would take a
slight bit extra programming on the application side. Before Qt
gnuplot terminal, I added a feature to the x11 terminal whereby an X
window ID can be passed into the gnuplot command "set term x11".
The concept is that the application creates a phantom X window
that it wants gnuplot to plot to. In that scenario, the X gnuplot
driver will not create a X term, but just plot into the external
window. Thus, if the X window is closed, the application should be
able to detect that. I remember writing some kind of demo using gtk
or one of those graphical interfaces that showed promise for a short
while.
It appears that Qt terminal has a similar sort of thing:
Syntax:
set term qt {<n>}
{size <width>,<height>}
{{no}enhanced}
{font <font>}
{title "title"}
{{no}persist}
{{no}raise}
{{no}ctrl}
{close}
{widget <id>}
So, if Octave can recognize that gnuplot is using qt terminal, it
would first create an empty Qt window and pass the ID (if it can be
discovered) to gnuplot. Octave would connect the close signal of
that Qt window to a slot that does "close(5)", for example... if
there were a background command queue (which I wrote in the patch
tracker somewhere).
In the documentation for the Qt Widget is this member function:
http://qt-project.org/doc/qt-__4.8/qwidget.html#__effectiveWinId
<http://qt-project.org/doc/qt-4.8/qwidget.html#effectiveWinId>
typedef WId
Platform dependent window identifier. I'll ask the list.
Be careful that the effective WinId is shared by multiple QWidget within
the same window. So you may end up with gnuplot drawing over other
widgets you might have in the window. You need to enable the native
windows flag on the widget if you want it to have its own X11 ID. Also
I'm wondering how portable to other platforms your suggestion is.