我注意到在 QT 中用 shared_ptr 替换原始指针时,我的代码不再工作了。例如,如果不是
QTreeWidgetItem* vItem(new QTreeWidgetItem(ItemTitle));
我用
std::shared_ptr<QTreeWidgetItem> vItem(new QTreeWidgetItem(ItemTitle));
然后,要么程序崩溃,要么什么都不做(即使我稍后在代码中使用 .get() 函数从共享指针中获取原始指针)。有谁知道可能是什么原因?