I cannot open a new window in QT. I new in QT so I think I am missing something. I only write the code below and settings windows just shows itself and closes. I开发者_运维知识库 have commented out destructor but still problem persists.
SettingsWindow s;
s.show();
What do I do wrong ? By the way I cannot either debug it, debuger does not stop when it reaches to the first line for example.
Thanks
This can't possibly be the only code you wrote.
However, judging from your description the first thing that comes to mind is probably a missing call to QApplication::exec()
. Somewhere in the code you haven't shown here there's an instance of QApplication
, probably named app
. After calling show
on your window, make sure there's a call to exec
.
Since you are using a non-pointer var, your window is destroy when it go our of scope (at the end of the function). If you use a pointer when exiting the function the memory is not deleted so you Windows will still be shown. But you will not be able to clean memory when closing the window if you can't anymore access to your pointer.
Maybe you need to create your window as member of the calling class in order to be able to destroy the window AND clean memory once you don't need anymore to display it (for example in the calling class destructor).
精彩评论