PDA

View Full Version : How to handle 2 QmainWindow closing problems



narendra
16th December 2009, 13:45
Hi,
Problem statement:
say we have 2 QMainWindow say A & B.
B is created from A on click of some button.
note A is not made as parent of the B (A->B). So basically now both A and B are independent. I chose this method because i don't want to inherit the style-sheet properties from A. I want the default which qt provides for window B. I do have some style-sheet set for A.
I want to close window B when A is closed if B is not closed already.

Actually B is crated by click of a button in the central widget of mainwindow A.

nish
16th December 2009, 14:24
in the close event of A .. just close B


void A::closeEvent(QCloseEvent*e)
{
b->close();
e->accept();
}

assuming you always keep the pointer of B with A