• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
我是张洪铭我是熊博士
时光静好,与君同;细水长流,与君语
博客园    首页    新随笔    联系   管理    订阅  订阅

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

 

posted @ 2019-12-10 15:13  我是张洪铭我是熊博士  阅读(1790)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3