[Qt-interest] Bug in QMdiArea or QMdiSubWindow wrt QCloseEvent under Linux but not Windows?
Andreas Ntaflos
daff at pseudoterminal.org
Sun Jun 14 04:59:56 CEST 2009
On Sunday 14 June 2009 04:19:57 rajasekharan wrote:
> Andreas,
>
> What method are you using in your QMainWindow to check if all the
> sub windows of the QMdiArea are closed?
Hi,
thank you for your reply. Like I said, the problem is (at least for
me) reproducible on Linux by running the MDI example in
examples/mainwindows/mdi in the Qt distribution, so my code shouldn't
really matter, should it?
My application uses almost exactly the same code for checking if
exiting is ok or not:
mdiArea->closeAllSubWindows();
if (activeProject()) {
event->ignore();
} else {
writeSettings();
event->accept();
}
activeProject() is like activeMdiChild() in the example:
if (QMdiSubWindow *activeSubWindow = mdiArea->activeSubWindow())
return qobject_cast<Project *>(activeSubWindow->widget());
return 0;
In this instance this apparently returns 0 even when the
activeSubWindow ignored the QCloseEvent. But it seems it only
(falsely) returns 0 when a call to closeAllSubWindows occured, as I
use the activeProject() method quite often throughout the main window
code and it always works correctly.
Did you try reproducing the described behaviour with the MDI example
application? Sidenote: I have several Qt versions installed here
(4.4.1, 4.4.3, 4.5.0 and 4.5.1) and they all exhibit this behaviour
in the MDI example.
> I have created an application with QMdiArea in Windows and Linux
> but didn't come across this issue. It worked correctly.
>
> In the QMainWindow's close event I used:
>
> mdiArea->closeAllSubWindows();
> if (midArea->subWindowList().size() > 0)
> {
> closeEvent->reject();
> }
> else
> {
> closeEvent->accept();
> }
Intersting, when using midArea->subWindowList().size() > 0 to check I
cannot reproduce the problem anymore! It works like it should. Now I
have at least a workaround, thank you :)
What does that mean? Probably at least that the MDI example is broken
in that regard, but why? Why shouldn't it work as expected?
Andreas
--
Andreas Ntaflos
Vienna, Austria
GPG Fingerprint: 6234 2E8E 5C81 C6CB E5EC 7E65 397C E2A8 090C A9B4
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2494 bytes
Desc: not available
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090614/da36262a/attachment.bin
More information about the Qt-interest-old
mailing list