Closing a new simple window in Qt

I am trying to make 2 windows. The second should be called in 1st. I do not bind their child-> parent. But when I called the 2nd window and closed it, I also closed the 1st window. What should I do? Both windows are derived from QWidget. C ++ and Qt


Too bad my poor describe. I have a main window. The class is inherited from QMainWindow. This I created the 2nd window. The class is inherited from QWidget. In the first (main window) I create and call the second window

ConfigWindow *ConfWindow = new ConfigWindow();
ConfWindow->show();

Without reference to the parent. Everything works fine, but when I close the second window (config-window), my main window closes too. I do not need this. What should I do to block the closing of the main window after closing the configuration window.

Hope to describe a little better.

My first window has these flags:

this->setWindowFlags(Qt::Tool | Qt::FramelessWindowHint);

. - , ?

+3
2

- :

QApplication app(argc, argv);
app.setQuitOnLastWindowClosed(false);

: http://pastebin.com/f5903c5f4.

, quit() .

QApplication:: quitOnLastWindowClosed documentation, , :

, , ( ) Qt:: WA_QuitOnClose. , -

() , . ConfWindow -. , ConfWindow, .

+10

, Qt .
Windows, - .
?


configWindow? Qt::WA_DeleteOnClose, .

ConfigWindow *confWindow = new configWindow();
configWindow->setAttribute(Qt::WA_DeleteOnClose, true);
confWindow->show();
0

Source: https://habr.com/ru/post/1710897/


All Articles