I want to open a simple QT dialog inside a std::thread, but it crashes after the dialog open success.

```
std::thread([&](){
    DialogWarning* dlg=new DialogWarning();
    dlg->setModal(true);
    dlg->exec();
    delete dlg;
}).detach();

```

What is the problem with this code?