QT小知识点(10) - QMessageBox使用注意内存泄露

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_22122811/article/details/85338323

A::A()  

{

    m_autoSendDatagramTimer = new QTimer(this);
    connect(m_autoSendDatagramTimer, SIGNAL(timeout()), this, SLOT(fun1()));
    m_autoSendDatagramTimer->setInterval(10);

}

void A::fun1()

{

    m_autoSendDatagramTimer->start();
    QMessageBox *messageBox = new QMessageBox(QMessageBox::NoIcon, "Warning", "",  QMessageBox::Ok, this);

}

隔10ms,创建一个QMessageBox指针,长时间就会造成内存泄露,(或者说内存大量被占用);

猜你喜欢

转载自blog.csdn.net/qq_22122811/article/details/85338323