Not sure of the crash, as you have not mentioned when the program crashes, or at least the stack trace.
Anyways following is a better, and good way to do. I recommend it this way,
{
Q_OBJECT
...
public:
...
static void Error
(QString value
) //diplays error message {
NDialog dlg("ERROR");
dlg.setAttribute(Qt::WA_DeleteOnClose,false);
dlg.AddWidget(&msg);
connect(&ok,SIGNAL(clicked()),&dlg,SLOT(close()));
dlg.AddWidget(&ok);
dlg.exec();
};
};
class NDialog : public QDialog
{
Q_OBJECT
...
public:
...
static void Error(QString value) //diplays error message
{
NDialog dlg("ERROR");
dlg.setAttribute(Qt::WA_DeleteOnClose,false);
QLabel msg(value);
dlg.AddWidget(&msg);
QPushButton ok("OK");
connect(&ok,SIGNAL(clicked()),&dlg,SLOT(close()));
dlg.AddWidget(&ok);
dlg.exec();
};
};
To copy to clipboard, switch view to plain text mode
or
{
Q_OBJECT
...
public:
...
static void Error
(QString value
) //diplays error message {
NDialog* dlg = new NDialog("ERROR");
dlg->setAttribute(Qt::WA_DeleteOnClose,false);
dlg->AddWidget(msg);
connect(ok,SIGNAL(clicked()),dlg,SLOT(close()));
connect(ok,SIGNAL(clicked()),dlg,SLOT(deleteLater()));
dlg->AddWidget(ok);
dlg->exec();
};
};
class NDialog : public QDialog
{
Q_OBJECT
...
public:
...
static void Error(QString value) //diplays error message
{
NDialog* dlg = new NDialog("ERROR");
dlg->setAttribute(Qt::WA_DeleteOnClose,false);
QLabel* msg = QLabel(value,dlg);
dlg->AddWidget(msg);
QPushButton* ok = new QPushButton ("OK", dlg);
connect(ok,SIGNAL(clicked()),dlg,SLOT(close()));
connect(ok,SIGNAL(clicked()),dlg,SLOT(deleteLater()));
dlg->AddWidget(ok);
dlg->exec();
};
};
To copy to clipboard, switch view to plain text mode
for both of the above examples you don't need to use WA_DeleteOnClose flag
Bookmarks