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
) : 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
) : ui(new Ui::dialog2)
{
ui->setupUi(this);
setParent(MdiArea);
setWindowTitle("Dialog2");
setWindowFlags(Qt::FramelessWindowHint);
setFocusPolicy(Qt::NoFocus);
ui->txtConnectionName->setFocus();
}
dialog2::~dialog2()
{
delete ui;
}
//**************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;
}
To copy to clipboard, switch view to plain text mode
when i closed the dialog2, dialog1 also comes out of eventloop without closing it....
Bookmarks