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:

Qt Code:
  1. void SLOTOkBtn()
  2. {
  3. QList<QTreeWidgetItem *> selectedItems = ui.m_PackageList->selectedItems();
  4.  
  5. if ( selectedItems.isEmpty() )
  6. {
  7. return;
  8. }
  9. else
  10. {
  11. // Provides you with the first selection
  12. m_Package = selectedItems.first()->text( 0 ).toAscii().data();
  13. QDialog::accept();
  14. }
  15. }
To copy to clipboard, switch view to plain text mode 

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