I know that qdialog->exec()
only returns if accept()
or reject()
is called. However I am using the following code:
mydialog* p =new mydialog(this);
p->setWindowModality(Qt::WindowModal);
int return_code= p->exec() ;//Block
if(return_code==1)
{
//Called when `accept()` is called --->Line A
}
else
{
//Called when reject is called ---> Line B
}
Now this method is called in mydialog
.
void mydialog::someMethod()
{
if(somecondition)
{
dialog_a->setWindowModality(Qt::WindowModal);
dialog_a->setFixedSize(dialog_a->size());
this->setVisible(false);
if(dialog_a->exec()==1)
{
qDebug() << "Dialog A selected";
}
else
{
//back button was pressesed
if(dialog_a->terminate)
{
reject();
}
else
{
this->setVisible(true); // --->Line C
}
}
}
else
{
qDebug() << "Something else selected";
}
}
Now here is the problem when the above method is called, it ends up in Line C. After that Line B is called. Why is that? Why is mydialog
is exiting? I havent called reject()
or accept()
anywhere?
Any suggestions?