unique_ptr在Qt项目中 [英] unique_ptr in Qt project

查看:429
本文介绍了unique_ptr在Qt项目中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的Qt项目。 I 包括< memory> ,但std :: unique_ptr不可用。我知道我应该使用Qt特定的智能指针,但我需要包括一个更大的项目包含std :: unique_ptr。

I have a simple Qt project. I include <memory> but std::unique_ptr is not available. I know that I should use Qt specific smart pointers but I need to include a larger project that contains std::unique_ptr.

我能做什么?

谢谢!

推荐答案

智能指针需要C ++ 11。根据您的Qt版本:

如果您有 Qt5 ,请将 CONFIG + = c ++ 11 以上。它需要包括< memory> ,如Simon所说。


如果你有比Qt5更早的版本,请尝试添加:

QMAKE_CXXFLAGS + = -std = c ++ 11

C++11 is required for smart pointers. Depending on your version of Qt:

Add CONFIG += c++11 to your .pro file if you have Qt5 and above. It needs to include <memory> as Simon mentioned.

If you have an earlier version than Qt5, try adding this:
QMAKE_CXXFLAGS += -std=c++11

这篇关于unique_ptr在Qt项目中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆