问题
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.
What can I do?
Thanks!
回答1:
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
回答2:
Include memory:
#include <memory>
Configure your Qt project to use C++11. Add to your .pro file:
CONFIG += c++11
If that does not solve the problem, please add a detailed error message.
来源:https://stackoverflow.com/questions/30031472/unique-ptr-in-qt-project