showing parent while closing child form
-
hi to all, I'm using qt 5.7 in centos7.5 linux. i want to show parent form while closing current child window. i am doing like this :-
void DialogAddModifyMemberRecords::on_pushButtonOK_clicked() { this->hide(); this->parentWidget()->show(); //this->close(); }
but shows error
```Starting /opt/projects/Qt/computerized billing sysem/cbs/build-cbs-Desktop_Qt_5_7_0_GCC_64bit-Debug/cbs... The program has unexpectedly finished. /opt/projects/Qt/computerized billing sysem/cbs/build-cbs-Desktop_Qt_5_7_0_GCC_64bit-Debug/cbs crashed.
how to get rid of this.
-
@rahulvishwakarma
Step through your code in debugger to determine exact cause (stack trace on crash). This is standard debugging technique before you ask question like this. One possibility: if your program is on default "quit after last window not visible", and child is only visible window, and you close before showing parent, I don't know if that could be a problem. Try showing parent before hiding child, just in case.Also, if this child is a
QDialog
, how is parent calling/showing it (exec()
, or is it modal/modeless??), and why is childhide()
-ing itself, dialogs often go viaaccept
/reject
/done()
?It's not always best design to have child show parent. Might be nicer to have parent notified of child closure so that it can re-show itself.
-
i used all choices you suggested(accept, reject ,done) and also setAttribute(Qt::WA_DeleteOnClose); in child and parent form.
but having same error :- The program has unexpectedly finished. -
@rahulvishwakarma said in showing parent while closing child form:
The program has unexpectedly finished
use debugger as already suggested
-
in debugger this showed following window at point of crash.
Signal name : SIGSEGV
Signal meaning : Segmentation fault -
@rahulvishwakarma You have to look at the stack trace (or post it here).
-
Does your
this
widget even have any parent? You don't check fornullptr
.