在一个QWidget主程序窗体中,用以下代码定义了一个自定义的QMessageBox;
但按确定关闭MessageBox时,主程序也关闭了。没有出现任何错误或异常。搞了很久不知什么原因。
试过用QMessageBox::Information(......)则没有问题。
QMessageBox test(this);
test.setIconPixmap(QPixmap(":/images/test.png"));
test.setWindowTitle(tr("test"));
test.setWindowFlags(Qt::WindowStaysOnTopHint);
test.setText(tr("%1\n=================================\n%2")
.arg(query.value(5).toString())
.arg(query.value(3).toString()));
test.exec();