Quote Originally Posted by wysota View Post
It depends when you call it. But one way or the other deleting the widget causes it to close so the effect will be the same.


Among other things, yes.


This will work but only because QDialog::exec() works in a special mode where it doesn't process deferred deletes.
The proper way to do it is either like so:
Qt Code:
  1. Dialog object;
  2. object.exec();
To copy to clipboard, switch view to plain text mode 
... or ...
Qt Code:
  1. Dialog *object = new Dialog;
  2. object->setAttribute(Qt::WA_DeleteOnClose);
  3. object->exec();
To copy to clipboard, switch view to plain text mode 
Well, my problem is that I have a dialog which is in fact a popup. I have the following flags set:

Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::Popup

Now I want, when the user clicks somewhere else than on the popup itself, that it disappears and deletes.

When I use exec(), it is modal, so can't click somewhere else to make it disappear.
So I use show() which does do this, but then the closeEvent is not sent, so it doesn't delete itself when the WA_DeleteOnClose has been set? However, finished() signal is send, so maybe I can do a close slot on this?