The usual behavior in a custom QDialog class is to emit one of the two signals "accepted()" or "rejected()" when the dialog is done. If you do not have OK or Cancel buttons, then you should emit those signals when VerifFiles determines if the result is successful or failed. If you use QDialog::exec() to post the dialog, you should not call "close()" from inside the dialog to close it, let the normal accept/reject mechanism do it for you.
// VerifFiles.cpp
void VerifFiles::lancerApp()
{
emit accepted();
}
// CZoneDessin.cpp
{
VerifFiles verif;
if ( QDialog::Rejected == verif.
exec() ) close();
}
// VerifFiles.cpp
void VerifFiles::lancerApp()
{
emit accepted();
}
// CZoneDessin.cpp
void CZoneDessin::showEvent( QShowEvent * )
{
VerifFiles verif;
if ( QDialog::Rejected == verif.exec() )
close();
}
To copy to clipboard, switch view to plain text mode
If you have to have a different code than QDialog::Accepted or QDialog::Rejected, you can emit the "finished( int )" signal instead and put your own integer code in there:
// VerifFiles.cpp
void VerifFiles::lancerApp()
{
emit finished( 42 );
}
// CZoneDessin.cpp
{
VerifFiles verif;
if ( 42 == verif.exec() )
close();
}
// VerifFiles.cpp
void VerifFiles::lancerApp()
{
emit finished( 42 );
}
// CZoneDessin.cpp
void CZoneDessin::showEvent( QShowEvent * )
{
VerifFiles verif;
if ( 42 == verif.exec() )
close();
}
To copy to clipboard, switch view to plain text mode
Bookmarks