Unique_ptr in Qt project

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

What can I do?

Thanks!

+7
c ++ qt unique-ptr
source share
2 answers

Smart pointers require C ++ 11. Depending on your version of Qt:

Add CONFIG += c++11 to your .pro file if you have Qt5 and higher. He should include <memory> , as Simon mentioned.

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

+7
source share

Enable memory:

 #include <memory> 

Configure your Qt project to use C ++ 11. Add the file to your .pro file:

 CONFIG += c++11 

If this does not solve the problem, add a detailed error message.

+3
source share

All Articles