I
I
Ilya Bobkov2015-01-31 13:24:42
Qt
Ilya Bobkov, 2015-01-31 13:24:42

Why is the window disappearing?

Hello! I create a dialog box on top of the standard MainWindow in the QT environment. I declare it Dialog dlg and call it dlg.show(), but it appears and disappears immediately, what could be the reason?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Y
Yaroslav, 2015-01-31
@heksen

For dialogs, call not show() as you would for a regular widget, but exec():
dlg.exec().

A
Armenian Radio, 2015-01-31
@gbg

With the fact that when you exit the scope of the dlg instance, the window is destroyed along with the instance. Create a dlg on the heap:
Dialog* dlg=new Dialog(...);
dlg->show();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question