QMap::remove操作,並不會調用值的析構,跟QTreeWidget同類,需要主動去釋放


void test_MapRemvoe()
{
    DBOperator * painter = new DBOperator;
    QMap<int , DBOperator*> map;
    map.insert(1, painter);
    DBOperator * painterOther = map.value(1);
    qDebug()<<painterOther;
    map.remove(1);

    qDebug()<<painterOther;
}

15:08:56: Starting E:\Qt_projcet\play\build-play-Desktop_Qt_5_12_2_MinGW_64_bit-Debug\debug\play.exe...

15:10:09: Debugging starts
DBOperator(0x1447800)  //remove前后地址是一樣的
DBOperator(0x1447800)  //remove前后地址是一樣的
15:10:41: Debugging has finished

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM