c++ - How to free an object after all slots were executed in Qt?
问题描述
I am facing an issue with Qt's signal and slot concept, as it is working asynchronously. I'm currently passing a pointer to an object which is created right before emitting a signal. I need to do this, because all receiving slots should use this object and be able to use the same state. I'm now running into problems, because I can't find a way to free the object after all the connected slots were executed. Is there an option for this?
解决方案
您可以使用QSharedPointer
. 当没有人再引用它时,它将自动销毁它所持有的对象。
推荐阅读
- javascript - 时刻 - fromNow 问题
- c# - 如何将 XML 属性值添加到包含对象的字典中
- python - 如何在桌面应用程序的机器人框架中模拟鼠标悬停
- python - 无法在 AWS Lambda 上运行 Google Vision API
- python-3.x - 如何在熊猫中获得类似的工作表名称
- clipboard - FPC 剪贴板查看器处理程序杀死了 Articulate Storyline 中的 Ctrl-X 功能
- string - 如何在新行中扫描cpp中带有空格的字符串?
- asp.net - Automapper.Initialize 方法未找到
- ruby - 如何避免 nogoriki to_html 将汉字编码为数字?
- xamarin.forms - 如何通过 xaml (xamarin.forms) 在列表视图中获取分组之间的空间