QMainWindow closes right after show()

后端 未结 1 1253
终归单人心
终归单人心 2021-01-26 10:07

I am new to Qt (use Objective-C mostly) so I am stuck with probably noob issue. From the QDialog window I try to open QMainWindow like this:

         


        
相关标签:
1条回答
  • 2021-01-26 10:41

    Your window is a local variable it is destroyed at the end of the function and hence the destructor closes it. What you could do is create the SQLWindow on the heap with new SQLWindow and e.g. use the Qt::WA_DeleteOnClose attribute as shown here.

    Alternatively, a better design might be to create both the dialog and the window as local variables of the main function and let the main function pass the path from the dialog to the SQLWindow, then you need no new.

    0 讨论(0)
提交回复
热议问题