doggrant
2nd February 2011, 10:22
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:
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();
QDialog::accept();
}
}
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
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:
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();
QDialog::accept();
}
}
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