Hi,

I'm working on a project using Qt Jambi, and I have come across something has me stumped, even though I have checked all the documentation and examples I could find (even C++ ones despite using Java).

The GUI for the application I'm working on shows a QListView and a QMdiArea, and when the user selects an option in the list, a QMdiSubWindow should appear in the QMdiArea.
The problem is, it does indeed appear... But only once. That is, if I close the subwindow and then click once again in the same option of the list, nothing happens. Furthermore, if I leave the subwindow open and click on the same option, a new subwindow appears, and the other remains open but content-less (the widget that it displayed disappears). This second issue is not really important since the user won't need a second instance of the same subwindow due to what the application does.

So, how am I supposed to handle subwindows in this case? Specifically, how do I close a subwindow and make it appear again as needed?
Currently I'm adding them by calling methods of classes that return a Qwidget (which contains other widgets conveniently put into layouts so it doesn't look ugly), and passing that widget to another method that puts it in a QMdiSubWindow and adds it to the QMdiArea. I haven't reimplemented the close event for the subwindows since I'm not subclassing QMdiSubWindow and it looks strange to imlement it in the class that provides the previously mentioned methods that return a QWidget. The close event in the main window (which houses the QMdiArea) looks like this:

Qt Code:
  1. public void closeEvent(QCloseEvent event) {
  2. //writeSettings();
  3. mdiArea.closeAllSubWindows();
  4. if (!mdiArea.subWindowList().isEmpty()) {
  5. event.ignore();
  6. } else {
  7. event.accept();
  8. }
  9. }
To copy to clipboard, switch view to plain text mode 

And the way I add the subwindows is as follows:

Qt Code:
  1. private void addNewSubWindow(QWidget widget, String title) {
  2. mdiArea.hide();
  3. QMdiSubWindow window = mdiArea.addSubWindow(widget);
  4. window.setWindowTitle(title);
  5. window.setAttribute(Qt.WidgetAttribute.WA_DeleteOnClose);
  6. mdiArea.show();
  7. }
To copy to clipboard, switch view to plain text mode 

Any ideas?