How to open MainWindow with signal
Solved
General and Desktop
-
I want to open MainWindow with button clicked signal, but the MainWindow close right after open it, why this happening?
Dialog dialog; dialog.show(); QObject::connect( &dialog, &Dialog::onSetClicked, [](const QString &port, const QString &config, const QString &model) { MainWindow demo(port, config, model); demo.show(); });
-
@isan said in How to open MainWindow with signal:
QObject::connect(
&dialog, &Dialog::onSetClicked,
[](const QString &port, const QString &config, const QString &model) {
MainWindow demo(port, config, model); --> local variable !
demo.show();
}); -
Hi,
You create demo in your lambda. It will be destroyed at the end of the function.