PDA

View Full Version : QWidget->close() doesn't actually close the QWidget



LucaDanieli
16th February 2017, 19:22
I have an application with many windows (QWidgets).

Particularly, each of these windows is called here SubWindow. Every SubWindow class contains a layout with a MultiEditor *sEditors, which has a menu with an action that closes the current window. Every SubWindow is created within the MainWindow.

In the SubWindow constructor I have:


connect(sEditors, SIGNAL(closeWindow()), this, SLOT(close()));
connect(this, SIGNAL(destroyed()), mainWindow, SLOT(closeWindow()));

The code actually works, as the slot closeWindow() is triggered. But the SubWindow doesn't disappear and remains visible.

Has anybody something to suggest me? I don't understand what actually the problem is (neither hide() seems to work).

Thanks!

anda_skoa
17th February 2017, 09:50
This is strange.

Are you triggering the closeWindow() slot elsewhere?

Because destroyed() is a signal of QObject so the widget destructor has already finished by then.
There should be no visual resource left at this point.

Cheers,
_