QDialog-derived form closes immediately

后端 未结 1 1757
灰色年华
灰色年华 2021-01-14 23:09

I am trying to make a form with data table appear when the button is clicked on thr main form. However, in practice second form \'blinks\' - appears less than on second - an

相关标签:
1条回答
  • 2021-01-14 23:57

    The problem is, that you have a local dialog object on the stack in your on_goodTable_clicked method. So you create the view, call show, which shows the dialog and immediately returns, then your view get's destroyed as you leave the function. If you make the dialog modal anyway, why not use QDialog's exec method intead of show. It shows the dialog and blocks the main window until you clicked the dialog's Ok or cancel button and then exec finally returns. When you want a non-modal dialog (meaning your main window works, while the dialog is open), you need to create your dialog dynamically (or make it a member of your main window, or both).

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