hi all, I need some help please...
I can't figure out why when I open a QMessageBox in my application and then press a button on it, the whole application quits...
my code:
// creating a main menubar to trigger the message box
{
fileM = menuBar()->addMenu("&File");
fileM->addAction(errWin);
connect(errWin, SIGNAL(triggered()), this, SLOT(ErrAlert()));
};
// creating a main menubar to trigger the message box
void MyClass::createMainMenu (QMainWindow* parent)
{
QAction* errWin = new QAction("Display Error", this);
QMenu* fileM = new QMenu(parent);
fileM = menuBar()->addMenu("&File");
fileM->addAction(errWin);
connect(errWin, SIGNAL(triggered()), this, SLOT(ErrAlert()));
};
To copy to clipboard, switch view to plain text mode
------------
// Message Box
void ErrAlert() {
msgBox->exec();
delete msgBox;
};
// Message Box
void ErrAlert() {
QMessageBox* msgBox = new QMessageBox("MSG Title" , "MSG Content", QMessageBox::Information,
QMessageBox::Yes, QMessageBox::No, QMessageBox::Cancel | QMessageBox::Escape);
msgBox->exec();
delete msgBox;
};
To copy to clipboard, switch view to plain text mode
// main.cpp
MyClass* bkm = new MyClass(mainW);
bkm->show();
// main.cpp
QMainWindow* mainW = new QMainWindow;
MyClass* bkm = new MyClass(mainW);
bkm->show();
To copy to clipboard, switch view to plain text mode
ok so the problem is that when I trigger the ErrAlert func. it works, by opening me the QMessageBox specified, but when I close it, it closes me the entire application... why is that happening, and how can I omit it?
please someone...
Bookmarks