PDA

View Full Version : Issues in nested QDialog



Askar
30th March 2011, 05:40
Dear Friends,
I am experiencing the following problem when i try to use nested QDialog. i had used .exec() to show those dialogs as modal. when i closed the second one, the first also comes out of the eventloop can any body help me to sort out this error.?


//**************slot to call dialog1**************************//

void SettingWnd::Slot_showDialog()
{
setEnabled(false);
setVisible(false);

dialog1 *dialogobj = new dialog1;
dialogobj->exec();

setVisible(true);
setEnabled(true);
btnDialup_setting->setFocus();
}

//**************Dialog 1**************************//


dialog1::dialog1(QWidget *parent) :
QDialog(parent),
ui(new Ui::dialog1)
{
ui->setupUi(this);
setParent(MdiArea);
setWindowTitle("Dialog1");
setWindowFlags(Qt::FramelessWindowHint);
setFocusPolicy(Qt::NoFocus);
if(ui->listWidget->count() == 0)
{
ui->listWidget->addItem("No connection added");
}
ui->listWidget->setFocus();
}

dialog1::~dialog1()
{
delete ui;
}

void dialog1::on_btnAdd_new_clicked()
{
setVisible(false);
setEnabled(false);

dialog2 *dialogObj1 = new dialog2;
dialogObj1->exec();

delete dialogObj1;
setVisible(true);
setEnabled(true);
ui->btnAdd_new->setFocus();
}

//**************Dialog 2**************************//

dialog2::dialog2(QWidget *parent) :
QDialog(parent),
ui(new Ui::dialog2)
{
ui->setupUi(this);
setParent(MdiArea);
setWindowTitle("Dialog2");
setWindowFlags(Qt::FramelessWindowHint);
setFocusPolicy(Qt::NoFocus);

ui->txtConnectionName->setFocus();
}

dialog2::~dialog2()
{
delete ui;
}

when i closed the dialog2, dialog1 also comes out of eventloop without closing it....

cbamber85
30th March 2011, 12:59
Have you tried instantiating dialog2 with dialog1 as the parent?


dialog2 *dialogObj1 = new dialog2(this);