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