QDialog.exec() exiting without calling QDialog::accept()
Hi,
In my code I have a dialog box which has an OK button. I show it by calling diag.exec(). The slot on the OK button has the following code:
Code:
void SLOTOkBtn()
{
QList<QTreeWidgetItem *> selectedItems = ui.m_PackageList->selectedItems();
if ( selectedItems.isEmpty() )
{
return;
}
else
{
// Provides you with the first selection
m_Package = selectedItems.first()->text( 0 ).toAscii().data();
}
}
Now if I hit OK and no items are selected, it gets to return;, which is what i would expect - however, rather than staying in exec(), it is closing the dialog box, and the test on the return code from diag.exec() give QDialog::Accepted, even though QDialog::Accept() has not been called.
Any ideas what i am doing wrong?
David
Re: QDialog.exec() exiting without calling QDialog::accept()
put some debug statements in both if and else block. See what isEmpty() returns.
Re: QDialog.exec() exiting without calling QDialog::accept()
I've put debuging in and also stepped through the code. That's how I know it's hitting the:
return;
and not:
QDialog::accept();
I just can't work out why the dialog box goes when QDialog::accept() has not been called.
Re: QDialog.exec() exiting without calling QDialog::accept()
provide a minimal compilable program reproducing the problem. there is no way to help without that.