PDA

View Full Version : close all messageboxes



av2306
24th November 2013, 09:22
Hi all,

My gui application opens different message boxes in different forms. I set parent to these message boxes as parent form. Created all messageboxes with QMessagebox::question(...). When I delete parent form (widget), It's throwing exception. If I change to NULL as a parent for message box, it's working fine.

Now, I want to close all message boxes before deleting widget (parent form).

Is there any qt api to close all opened message boxes in application?

Thanks.

rohitkk
24th November 2013, 10:00
Hi,
You can directly set the dialog as modal in ui, that will not allow any parent to get closed before its child window.

Regards,
Rohit

DON'T WALK IN THE WORLD AS IF YOU RULE THE WORLD , WALK AS IF SOMEONE RULES AND YOU DON'T CARE.....

anda_skoa
24th November 2013, 12:06
Is there any qt api to close all opened message boxes in application?


Not specifically for QMessageBox, but you could probably us QObject::findChildren<QMessageBox*>() on your parent and then loop over the list and call close() on each.

Maybe together with delayed deletion of the parent using deleteLater().

Cheers,
_