From what I understand, in order to make the Modeless dialog, you have to allocate it in a heap. Having done something like this:
MyDialog* dlg = new MyDialog(this); dlg->show(); dlg->raise();
Since exec () ignores the Modal property. However, a memory leak now occurs, since nothing frees the memory pointed to by the dlg pointer until the application is closed. I found one solution here http://tinf2.vub.ac.be/~dvermeir/manuals/KDE20Development-html/ch08lev1sec3.html#ch08list09 at the end of the page and wondered if there was a less cumbersome way to have a Modeless dialog.
finished deleteLater:
void MyDialog::MyDialog(QWidget *parent) { // ... connect(this, SIGNAL(finished(int)), SLOT(deleteLater))); }
, finished ( , , , ).
finished
Qt:: WA_DeleteOnClose, , /, QWeakPointer ( QPointer) /, :
void MyWindow::openDialog() { static QWeakPointer<MyDialog> dlg_; if (!dlg_) dlg_ = new MyDialog(this); MyDialog *dlg = dlg_.data(); dlg->setAttribute(Qt::WA_DeleteOnClose); dlg->show(); dlg->raise(); dlg->activateWindow(); }
dlg->setAttribute(Qt::WA_DeleteOnClose);
a -dynamically alloc-member, .. :
// constructor : dialog_(0) // member function { if (! dialog_) dialog_ = new MyDialog(this); dialog_->show(); dialog_->raise(); }
, , .