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

Source for the only close event I implemented (the one for the main window)
is like this:

public void closeEvent(QCloseEvent event) {
        //writeSettings();
        mdiArea.closeAllSubWindows();
        if (!mdiArea.subWindowList().isEmpty()) {
            event.ignore();
        } else {
            event.accept();
        }
}

And the method to create and add a subwindow is as follows:

private void addNewSubWindow(QWidget widget, String title) {
        mdiArea.hide();
        QMdiSubWindow window = mdiArea.addSubWindow(widget);
        window.setWindowTitle(title);
        window.setAttribute(Qt.WidgetAttribute.WA_DeleteOnClose);
        mdiArea.show();
}

Any ideas on what I'm doing wrong? I think the problem might come from the
subwindow being in the subwindow list of the QMdiArea even after being
closed, but then ¿shouldn't using DeleteOnClose have fixed it?
_______________________________________________
Qt-jambi-interest mailing list
[email protected]
http://lists.trolltech.com/mailman/listinfo/qt-jambi-interest

Reply via email to