Try this
#include <qapplication.h>
#include <qevent.h>
#include <qpushbutton.h>
#include <qdialog.h>
#include <qmessagebox.h>
#include <iostream>
{
public:
}
protected:
event->ignore();
QMessageBox::information( this,
"Close?",
"Close? No way!" );
}
};
int main( int argc, char** argv )
{
MyDialog dlg;
QObject::connect( button,
SIGNAL( clicked
() ),
&app, SLOT( quit() ) );
dlg.resize( 300, 300 );
dlg.show();
return app.exec();
}
#include <qapplication.h>
#include <qevent.h>
#include <qpushbutton.h>
#include <qdialog.h>
#include <qmessagebox.h>
#include <iostream>
class MyDialog : public QDialog
{
public:
MyDialog( QWidget* parent=0 ) : QDialog( parent ) {
}
protected:
void closeEvent ( QCloseEvent * event ) {
event->ignore();
QMessageBox::information( this, "Close?", "Close? No way!" );
}
};
int main( int argc, char** argv )
{
QApplication app( argc, argv );
MyDialog dlg;
QPushButton* button = new QPushButton( "Exit", &dlg );
QObject::connect( button, SIGNAL( clicked() ),
&app, SLOT( quit() ) );
dlg.resize( 300, 300 );
dlg.show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks