PDA

View Full Version : QDialog ?



allensr
27th November 2007, 22:04
I've got a simple app (no functionality yet, just laying it out) that opens with a dialog box with 2 buttons. If you hit one button another Dialog box opens and when you hit OK/Cancel from that Dialog control goes back to the original dialog. If you hit the other button the otherDialog box opens but when you hit OK/Cancel from that dialog, once it closes out and the original dialog box comes back into view, I can't click on the original dialog anymore. It's like it's grayed out. I just hear a ding in the background each time I try to click anywhere on it. I can't see anything that I'm doing differently between the 2. Are there any parenting issues involved here?

in my header for the main dialog box


class cMainWindowDlg : public QDialog, public Ui::cMainWindowDlg
{
Q_OBJECT

public:
cMainWindowDlg(QWidget * parent = 0);
virtual ~cMainWindowDlg();
void setupUi();

private slots:
// Automatically connected slots. Note these slots follow the naming convention
// on_objectName_signalName()

void on_mOkButton_clicked();
void on_mCancelButton_clicked();
void on_mLaborCategoryButton_clicked();
void on_mContractButton_clicked();

private:
cLaborCategoryDlg * mLaborCategoryDlg;
cContractDataQueryDlg * mContractDataDlg;
}; // cMainWindowDlg

the constructor for main dialog box


////////////////////////////////////////////////////////////////////////////////
cMainWindowDlg::cMainWindowDlg(QWidget * parent) :
QDialog(parent),
mLaborCategoryDlg(0),
mContractDataDlg(0)
{
// Note that setupUi() will also automatically connect any slots that follow
// the naming conventions.
setupUi();

mLaborCategoryDlg = new cLaborCategoryDlg(this); //Managed by Qt

mContractDataDlg = new cContractDataQueryDlg(this); //Managed by Qt

} // cMainWindowDlg::cMainWindowDlg
void cMainWindowDlg::setupUi()
{
Ui_cMainWindowDlg::setupUi(this); // Must call the base class setupUi first

} // cMainWindowDlg::setupUi


the 2 buttons that open up the other dialog boxes


void cMainWindowDlg::on_mLaborCategoryButton_clicked()
{
bool accepted(mLaborCategoryDlg->exec())); //true=>OK false=>Cancel
}
void cMainWindowDlg::on_mContractButton_clicked()
{
bool accepted(mContractDataDlg->exec())); //true=>OK false=>Cancel
}

jacek
27th November 2007, 22:44
How do you "close" that otherDialog in your code?

rajesh
28th November 2007, 05:41
do you want to open multiple dialog by clicking first button?

allensr
28th November 2007, 14:42
I close each dialog the same way.

The one that "works"


////////////////////////////////////////////////////////////////////////////////
void cLaborCategoryDlg::on_mOkButton_clicked()
{
accept();
} // cLaborCategoryDlg::on_mOkButton_clicked

////////////////////////////////////////////////////////////////////////////////
void cLaborCategoryDlg::on_mCancelButton_clicked()
{
reject();
} // cLaborCategoryDlg::on_mCancelButton_clicked


The one that doesn't:


////////////////////////////////////////////////////////////////////////////////
void cContractDataQueryDlg::on_mOkButton_clicked()
{
accept();
} // cContractDataQueryDlg::on_mOkButton_clicked

////////////////////////////////////////////////////////////////////////////////
void cContractDataQueryDlg::on_mCancelButton_clicked()
{
reject();
} // cContractDataQueryDlg::on_mCancelButton_clicked

jacek
28th November 2007, 15:19
Have you reimplemented accept(), reject() or exec() in cContractDataQueryDlg?

allensr
28th November 2007, 15:22
No, I haven't.

allensr
28th November 2007, 17:49
I figured it out. In the dialog box that wasn't closing out properly, I had several checkboxes, and for some reason, one of the checkboxes had Qt::ApplicationModal set :o

Anyway, set it to Qt::NonModal like all of the rest, and it works fine now.

Thanks to all who replied.

wysota
28th November 2007, 19:35
I close each dialog the same way.

The one that "works"


////////////////////////////////////////////////////////////////////////////////
void cLaborCategoryDlg::on_mOkButton_clicked()
{
accept();
} // cLaborCategoryDlg::on_mOkButton_clicked

////////////////////////////////////////////////////////////////////////////////
void cLaborCategoryDlg::on_mCancelButton_clicked()
{
reject();
} // cLaborCategoryDlg::on_mCancelButton_clicked



Do you know that these slots are redundant? You might have done:

connect(mOkButton, SIGNAL(clicked()), this, SLOT(accept()));
connect(mCancelButton, SIGNAL(clicked()), this, SLOT(reject()));

Or even make the connection graphically in Designer.